Open AriHrannar opened 7 years ago
@Ragnar-Hardarson do you feel like taking this one? Since you did something similar in the master thesis :)
GET on /subjects
fetches all subjects.
I have added a few choices as query parameters to allow for filtering.
Case insensitive startswith search ( I think this is the best one to start with at least)
/subjects?name__istartswith=S
Returns everything that starts with "S" or "s"
Case sensitive startswith search
/subjects?name__startswith=S
Returns everything that starts with "S"
Contains search
/subjects?name__contains=S
returns everything containing "S"
Exact match
/subjects?name__exact=S
Returns everything that matches "S" exactly
POST to /subjects/
with the following payload
{
"name": "Subject"
}
Name is the only required attribute. Others (parliament_session, description, number and parent) are for when we harvest subjects from althingi.
If a new subject is created, the returned object looks like this
{
"id": 5,
"name": "Zubject",
"created": "2017-06-10T14:06:32.542308Z",
"modified": "2017-06-10T14:06:32.542331Z",
"description": null,
"parliament_session": null,
"number": null,
"parent": null
}
and the status code is 201.
If the subject (matched using the name) already exists in the database then nothing is created in the database. The object is simply returned (see above) with the status code 200. The name is not case sensitive (subject and suBject are the same) and the name is always capitalized on the backend (turning subject into Subject)
Can the server respond with an error code when the subject already exists? I think that's clearer from the web end of things
yeah thats no problem. My idea was that we still want it to be a "success" from the users perspective but its a 1 line change if its better
What is a definition of a "user" here? Is it an admin or should all users be able to add subjects/tags to promises?
Good point, that is something we have been discussing.
As far as I can remember from our last talk @Ragnar-H we are going with
I can see benefits in creating the Subjects in the same action as creating the Promise (maybe even requiring a few Subjects when creating a Promise, as Promises are useless without the Subjects really)
If we allow everyone to create Subjects however, we are back in the discussion about spammers :)
So am I right in assuming that only admins can add subjects to an already created promise? Also, do you support removing subjects?
So am I right in assuming that only admins can add subjects to an already created promise?
Yes. Maybe a "suggest a subject" for normal users could be made later.
Also, do you support removing subjects?
WIP Not right now, but I'm working on it :)
Description
The user should be able to add tags (called subjects on the backend) to the promises both when he is creating them and after they have been created