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

Overhaul dashboard, add Todos, and improve typography #422

Merged
merged 29 commits into from
Oct 20, 2017

Conversation

marcua
Copy link
Member

@marcua marcua commented Oct 15, 2017

This PR does three things:

  • Replaces the dashboard cards with tables for Active/Pending/Completed tasks
  • Adds a Todo, which any collaborator on a project can create/check off, but is assigned to particular tasks/roles on a project
  • Some CSS improvements, including moving our font stack over to the system font stack. Night and day improvement to our typography.

Great example of a terrible PR in that it does three things at once. This was the result of a B12 hackathon, and I'm getting it out there rather than keeping it under wraps. If reviewing it is too much of a headache, I can break it into smaller PRs.

TODO

  • Small amount of CSS work on the todo list
  • Truncate details in table if they get too long
  • Try to integrate angular-smart-table for sorting/searching/pagination. Can always go in a v2.

</div>
</div>
</section>
<!--/section-panel tasks-section -->
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

@marcua marcua changed the title [WIP] Overhaul dashboard, add TODOs, and improve typography Overhaul dashboard, add TODOs, and improve typography Oct 17, 2017
@marcua marcua requested a review from kkamalov October 17, 2017 02:57
@marcua marcua changed the title Overhaul dashboard, add TODOs, and improve typography Overhaul dashboard, add Todos, and improve typography Oct 17, 2017
@@ -64,14 +64,14 @@ export function orchestraService () {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the only thing that changed in style.css above is the font stack moving over to the system fonts. the diff is large because of whitespace cleanup.

"""
This function is used by both the project management interface
(project admins only) and for providing project information to
experts (only to experts associated with a project). We enfoce
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enforce

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

project_id = load_encoded_json(request.body)['project_id']
worker = Worker.objects.get(user=request.user)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_object_or_404

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe put in 1 migration?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -64,14 +64,14 @@ export function orchestraService () {

export function orchestraTasks ($http) {
'ngAnnotate'
const activeState = (task) => task.state === 'in_progress' || task.state === 'returned' || task.state === 'just_added'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

['just_added', 'in_progress', 'returned'].indexOf(task.state) !== -1

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}
return tasks
},
allTasks: function () { return this.tasks },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this function () be replaced with () => below?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i initially did just this to "modernize" this part of the code, but ran into an issue---the object syntax we're using to create these functions on orchestraTasks requires this be bound in a way that function definitions do, and modern () => definitions do not.

i propose we modernize the whole module in a separate PR :)

worker = get_object_or_404(Worker, user=request.user)
if not (is_project_admin(request.user) or
worker.assignments.filter(task__project=project_id).exists()):
raise BadRequest('Permission denied')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be a 403 or 404 on Permission denied, not a 400?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also looks like you created nice permission classes for this in your PR, can they be reused here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

@marcua marcua Oct 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

permission_classes by default can only be ANDed, not ORed. This project addresses that, and we can consider depending on it in a followon PR

Copy link
Member

@thisisdhaas thisisdhaas Oct 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to win an argument, just return Django's PermissionDenied.

That project looks useful, but I don't really think our security needs are complex enough to merit adding dependencies.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -14,4 +14,5 @@
from orchestra.models.core.models import Iteration # noqa
from orchestra.models.core.models import TimeEntry # noqa
from orchestra.models.core.models import TaskTimer # noqa
from orchestra.models.core.models import Todo # noqa
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like you complained about this to me :-)

If you leave this here, the way to get rid of the noqas is to define __all__, which makes some sense if the point of this code is to gather a bunch of symbols in one module. (Though python people fight about it a lot).

Copy link
Member Author

@marcua marcua Oct 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did __all__

overall i dislike this model of doing things, but refactors/cleanups on this PR are out of the question :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: but now you should be able to remove all the # noqas.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -61,6 +61,9 @@ def __str__(self):
self.phone
)

def formatted_slack_username(self):
return '<@{}|{}>'.format(self.slack_user_id, self.slack_username)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecated (see https://api.slack.com/changelog/2017-09-the-one-about-usernames), they want you to just pass the user_id and let them figure out the display name.

Copy link
Member Author

@marcua marcua Oct 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. Thanks! I didn't know that.

return False


class TodoList(generics.ListCreateAPIView):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No good viewsets to let you combine the list and detail views?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that I could find :P

if next_todo:
next_todo_description = next_todo.description
num_todos = task_assignment.task.todos.count()
should_be_active = ((num_todos == 0) or
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why active if there are no todos?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added comment explaining why :)

<td>{{task.detail}}</td>
<td>{{task.next_todo_description}}</td>
<td>{{task.detail|limitTo:50}}{{task.detail.length > 50 ? '...' : ''}}</td>
<td>{{task.next_todo_description|limitTo:50}}{{task.next_todo_description.length > 50 ? '...' : ''}}</td>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there pagination? Or does this make it impossible to see > 50 tasks? (i.e., what if Kirstin needs to work on task 51?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this truncates text to 50 characters so the table doesn't wrap

@marcua marcua merged commit 3a63440 into master Oct 20, 2017
@marcua marcua deleted the dashboard-todo-overhaul branch October 20, 2017 13:36
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

Successfully merging this pull request may close these issues.

3 participants