Skip to content

Commit

Permalink
Merge pull request #1331 from diegoaces/master
Browse files Browse the repository at this point in the history
Columns are added to the projects view in administration.
  • Loading branch information
pierotofy authored Apr 27, 2023
2 parents ecd89a3 + 2ee0033 commit ff0d4b5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@
from django.core.files.uploadedfile import InMemoryUploadedFile
from django.utils.translation import gettext_lazy as _, gettext

admin.site.register(Project, GuardedModelAdmin)

class ProjectAdmin(GuardedModelAdmin):
list_display = ('id', 'name', 'owner', 'created_at', 'tasks_count', 'tags')
list_filter = ('owner',)
search_fields = ('id', 'name', 'owner__username')


admin.site.register(Project, ProjectAdmin)


class TaskAdmin(admin.ModelAdmin):
Expand Down
3 changes: 3 additions & 0 deletions app/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ def __str__(self):
def tasks(self):
return self.task_set.only('id')

def tasks_count(self):
return self.task_set.count()

def get_map_items(self):
return [task.get_map_items() for task in self.task_set.filter(
status=status_codes.COMPLETED
Expand Down

0 comments on commit ff0d4b5

Please sign in to comment.