GET /administrator/restfulsimplifiedcandidate/

Search for candidates.

The underlying data model searched is defined in devilry.apps.core.models.Candidate. The Simplified API that the server forwards this request to is devilry.apps.administrator.simplified.simplifiedcandidate.SimplifiedCandidate.search().

The request parameters (below) all modify the result of the search. They are applied in the following order:

  1. The query is executed.
  2. The result of the query is filtered through the filters.
  3. The result of the filtering is ordered as specified in orderby.
  4. The result of the ordering is limited by start and limit.

Request

Request example

GET /administrator/restfulsimplifiedcandidate/

{
    query: 'a query string',
    filters: [{field:"assignment_group", comp:"endswith", value:15},
                  {field:"assignment_group__parentnode", comp:"<", value:15},
                  {field:"assignment_group__parentnode__parentnode", comp:">=", value:15}],
    orderby: ["student", "-candidate_id", "id", "identifier", "full_name", "email", "assignment_group"],
    start: 10,
    limit: 100
}

Optional request parameters

Optional request parameters are encoded as a JSON object and sent as the request body as shown in the example above.

query

A string to search for. If this is empty or not given, all candidates that the authenticated user has access to is returned.

If the string is not empty, the query-string is split on whitespace, resulting in a list of words. Every word in the list is searched for case-insensitive matches within the following fields:

identifier
Actual location of the field:
devilry.apps.core.models.Candidate
About the field:
The candidate_id if this is a candidate on an anonymous assignment, and username if not.
Type
String

filters

Filters can be used to perform complex queries. The filters parameter is a list of filters, where each filter is a map with the following entries:

field
A field name.
comp
A comparison operator.
value
The value to filter on.

Example:

[{field:"assignment_group", comp:"endswith", value:15},
 {field:"assignment_group__parentnode", comp:"<", value:15},
 {field:"assignment_group__parentnode__parentnode", comp:">=", value:15}]

candidates can be filtered on the following fields:

assignment_group
Actual location of the field:
devilry.apps.core.models.AssignmentGroup
About the field:
Autogenerated identifier.
Type
Integer
Supported comparison operators:
startswith, contains, >=, <=, icontains, iexact, endswith, exact, <, >.
assignment_group__parentnode
Actual location of the field:
devilry.apps.core.models.Assignment
About the field:
Autogenerated identifier.
Type
Integer
Supported comparison operators:
startswith, contains, >=, <=, icontains, iexact, endswith, exact, <, >.
assignment_group__parentnode__parentnode
Actual location of the field:
devilry.apps.core.models.Period
About the field:
Autogenerated identifier.
Type
Integer
Supported comparison operators:
startswith, contains, >=, <=, icontains, iexact, endswith, exact, <, >.
assignment_group__parentnode__parentnode__parentnode
Actual location of the field:
devilry.apps.core.models.Subject
About the field:
Autogenerated identifier.
Type
Integer
Supported comparison operators:
startswith, contains, >=, <=, icontains, iexact, endswith, exact, <, >.
id
Actual location of the field:
devilry.apps.core.models.Candidate
About the field:
Autogenerated identifier.
Type
Integer
Supported comparison operators:
startswith, contains, >=, <=, icontains, iexact, endswith, exact, <, >.

exact_number_of_results

If given, this must be a positive integer (including 0), which specifies the exact number of expected results. This enables searches that you know should fail if they do not get this exact number of results, such as filtering for a User by unique username instead of its numeric ID (where you should expect exactly one result).

orderby

List of fieldnames. Order the result by these fields. Fieldnames can be prefixed by '-' for descending ordering.

start

After query, filters and orderby have been executed, the result is limited to the values from start to start+limit. Start defalts to 0.

limit

Limit results to this number of items. Defaults to 50.

Response

On success

Example

note that the is wrong in the example. The id is always unique. However, the example is generated from a non-varying dataset.

200 OK

{
    total: 20,
    items: [
        { student: 15,
          candidate_id: "My example value",
          id: 15,
          identifier: "My example value",
          full_name: "My example value",
          email: "My example value",
          assignment_group: 15 },
        { student: 15,
          candidate_id: "My example value",
          id: 15,
          identifier: "My example value",
          full_name: "My example value",
          email: "My example value",
          assignment_group: 15 },
        ...
    ]
}

Success response details

Responds with HTTP code 200 and a JSON encoded dict containing the list of results and the total number of items found before applying limit and start. Each result in the list is a JSON object where the key is a fieldname and the associated value is the value for that field. The result always contains the following fields:

student
Actual location of the field:
django.contrib.auth.models.User
About the field:
Autogenerated identifier.
Type
Integer
candidate_id
Actual location of the field:
devilry.apps.core.models.Candidate
About the field:
An optinal candidate id. This can be anything as long as it is less than 30 characters.
Type
String
id
Actual location of the field:
devilry.apps.core.models.Candidate
About the field:
Autogenerated identifier.
Type
Integer
identifier
Actual location of the field:
devilry.apps.core.models.Candidate
About the field:
The candidate_id if this is a candidate on an anonymous assignment, and username if not.
Type
String
full_name
Actual location of the field:
devilry.apps.core.models.Candidate
About the field:
None if this is a candidate on an anonymous assignment, and full name if not.
Type
String
email
Actual location of the field:
devilry.apps.core.models.Candidate
About the field:
None if this is a candidate on an anonymous assignment, and email address if not.
Type
String
assignment_group
Actual location of the field:
devilry.apps.core.models.AssignmentGroup
About the field:
Autogenerated identifier.
Type
Integer

On error

On errors, we respond with one of the HTTP Error status codes.