Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error using Requests to PUT task status #20

Open
clebio opened this issue Sep 24, 2016 · 2 comments
Open

Error using Requests to PUT task status #20

clebio opened this issue Sep 24, 2016 · 2 comments

Comments

@clebio
Copy link

clebio commented Sep 24, 2016

So, trying to follow along with Chapter 6, I hit the API via requests:

import requests
import datetime
response = requests.get('http://localhost:9000/api/tasks', auth=('admin', 'admin'))
tasks = response.json()
t0 = tasks['results'][0]
t0['assigned'] = 'admin'
t0['status'] = 2
today = datetime.date.today()
t0['started'] = today
response = requests.put(t0['links']['self'], data=t0, auth=('admin', 'admin'))

But when I PUT the task back, I'm met with a 400 response:

In [21]: response = requests.put(t0['links']['self'], data=t0, auth=('admin', 'admin'))
In [22]: response.text
Out[22]: u'{"non_field_errors":["Backlog tasks must have \\"Not Started\\" status."]}'

I'm also a bit confused, and perhaps this is related, about the statuses as defined in the models versus in the Backbone UI:

In [27]: from board import models
In [28]: models.Task.STATUS_TODO
Out[28]: 1

Whereas when I hit up http://localhost:9000/#sprint/1, I see five statuses:
Backlog, Not Started, In Development, In Testing, Completed

I haven't dug too far down yet, but it seems like there's a conflict in the STATUS codes:
https://github.com/lightweightdjango/examples/blob/chapter-6/scrum/board/static/board/js/views.js#L307

            this.statuses = {
                unassigned: new StatusView({
                    sprint: null, status: 1, title: 'Backlog'}),
                todo: new StatusView({
                    sprint: this.sprintId, status: 1, title: 'Not Started'}),
                active: new StatusView({
                    sprint: this.sprintId, status: 2, title: 'In Development'}),
                testing: new StatusView({
                    sprint: this.sprintId, status: 3, title: 'In Testing'}),
                done: new StatusView({
                    sprint: this.sprintId, status: 4, title: 'Completed'})
            };

versus
https://github.com/lightweightdjango/examples/blob/chapter-6/scrum/board/models.py#L20

    STATUS_TODO = 1
    STATUS_IN_PROGRESS = 2
    STATUS_TESTING = 3
    STATUS_DONE = 4

    STATUS_CHOICES = (
        (STATUS_TODO, _('Not Started')),
        (STATUS_IN_PROGRESS, _('In Progress')),
        (STATUS_TESTING, _('Testing')),
        (STATUS_DONE, _('Done')),
    )
@clebio
Copy link
Author

clebio commented Sep 24, 2016

Also, 👍 to the suggestion from #2 that there should be a requirements.txt for each chapter. Without a careful reading of the text, one has to sort of fumble through what pip installs are needed.

@mlavin
Copy link
Contributor

mlavin commented Sep 26, 2016

"Backlog" in our model is not another status but rather denotes tasks which are not assigned to a sprint. The UI needs to display them in the sprint detail so that they can be moved into the sprint via drag and drop. In our application we've chosen to enforce that tasks which are not part of a sprint must have the status of TODO. You're seeing that enforced in the PUT call because it attempts to change the status without assigning a sprint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants