From 3111cf79eb5642b24ed57bbd0b0465f8e7b853ba Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Tue, 18 Aug 2015 10:49:05 +0200 Subject: [PATCH] Improving admin --- taiga/projects/admin.py | 5 ++++- taiga/projects/issues/admin.py | 5 ++++- taiga/projects/milestones/admin.py | 3 +++ taiga/projects/notifications/admin.py | 25 +++++++++++++++++++++++++ taiga/projects/tasks/admin.py | 5 ++++- taiga/projects/userstories/admin.py | 4 +++- taiga/projects/votes/admin.py | 25 +++++++++++++++++++++++++ taiga/projects/votes/models.py | 2 +- taiga/projects/wiki/admin.py | 5 ++++- 9 files changed, 73 insertions(+), 6 deletions(-) create mode 100644 taiga/projects/notifications/admin.py create mode 100644 taiga/projects/votes/admin.py diff --git a/taiga/projects/admin.py b/taiga/projects/admin.py index f3eea353..5dcc9758 100644 --- a/taiga/projects/admin.py +++ b/taiga/projects/admin.py @@ -17,7 +17,10 @@ from django.contrib import admin from taiga.projects.milestones.admin import MilestoneInline +from taiga.projects.notifications.admin import WatchedInline +from taiga.projects.votes.admin import VoteInline from taiga.users.admin import RoleInline + from . import models class MembershipAdmin(admin.ModelAdmin): @@ -35,7 +38,7 @@ class ProjectAdmin(admin.ModelAdmin): list_display = ["name", "owner", "created_date", "total_milestones", "total_story_points"] list_display_links = list_display - inlines = [RoleInline, MembershipInline, MilestoneInline] + inlines = [RoleInline, MembershipInline, MilestoneInline, WatchedInline, VoteInline] def get_object(self, *args, **kwargs): self.obj = super().get_object(*args, **kwargs) diff --git a/taiga/projects/issues/admin.py b/taiga/projects/issues/admin.py index 16da297e..fe891719 100644 --- a/taiga/projects/issues/admin.py +++ b/taiga/projects/issues/admin.py @@ -17,13 +17,16 @@ from django.contrib import admin from taiga.projects.attachments.admin import AttachmentInline +from taiga.projects.notifications.admin import WatchedInline +from taiga.projects.votes.admin import VoteInline + from . import models class IssueAdmin(admin.ModelAdmin): list_display = ["project", "milestone", "ref", "subject",] list_display_links = ["ref", "subject",] - # inlines = [AttachmentInline] + inlines = [WatchedInline, VoteInline] def get_object(self, *args, **kwargs): self.obj = super().get_object(*args, **kwargs) diff --git a/taiga/projects/milestones/admin.py b/taiga/projects/milestones/admin.py index b741a1b2..52919e87 100644 --- a/taiga/projects/milestones/admin.py +++ b/taiga/projects/milestones/admin.py @@ -15,6 +15,8 @@ # along with this program. If not, see . from django.contrib import admin +from taiga.projects.notifications.admin import WatchedInline +from taiga.projects.votes.admin import VoteInline from . import models @@ -30,6 +32,7 @@ class MilestoneAdmin(admin.ModelAdmin): list_display_links = list_display list_filter = ["project"] readonly_fields = ["owner"] + inlines = [WatchedInline, VoteInline] admin.site.register(models.Milestone, MilestoneAdmin) diff --git a/taiga/projects/notifications/admin.py b/taiga/projects/notifications/admin.py new file mode 100644 index 00000000..2dc22d61 --- /dev/null +++ b/taiga/projects/notifications/admin.py @@ -0,0 +1,25 @@ +# Copyright (C) 2014 Andrey Antukh +# Copyright (C) 2014 Jesús Espino +# Copyright (C) 2014 David Barragán +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from django.contrib import admin +from django.contrib.contenttypes.admin import GenericTabularInline + +from . import models + + +class WatchedInline(GenericTabularInline): + model = models.Watched + extra = 0 diff --git a/taiga/projects/tasks/admin.py b/taiga/projects/tasks/admin.py index 937e70a3..5295e7ca 100644 --- a/taiga/projects/tasks/admin.py +++ b/taiga/projects/tasks/admin.py @@ -17,6 +17,9 @@ from django.contrib import admin from taiga.projects.attachments.admin import AttachmentInline +from taiga.projects.notifications.admin import WatchedInline +from taiga.projects.votes.admin import VoteInline + from . import models @@ -24,7 +27,7 @@ class TaskAdmin(admin.ModelAdmin): list_display = ["project", "milestone", "user_story", "ref", "subject",] list_display_links = ["ref", "subject",] list_filter = ["project"] - # inlines = [AttachmentInline] + inlines = [WatchedInline, VoteInline] def get_object(self, *args, **kwargs): self.obj = super().get_object(*args, **kwargs) diff --git a/taiga/projects/userstories/admin.py b/taiga/projects/userstories/admin.py index cd23dc35..9cb3e667 100644 --- a/taiga/projects/userstories/admin.py +++ b/taiga/projects/userstories/admin.py @@ -17,6 +17,8 @@ from django.contrib import admin from taiga.projects.attachments.admin import AttachmentInline +from taiga.projects.notifications.admin import WatchedInline +from taiga.projects.votes.admin import VoteInline from . import models @@ -41,7 +43,7 @@ class UserStoryAdmin(admin.ModelAdmin): list_display = ["project", "milestone", "ref", "subject",] list_display_links = ["ref", "subject",] list_filter = ["project"] - inlines = [RolePointsInline] + inlines = [RolePointsInline, WatchedInline, VoteInline] def get_object(self, *args, **kwargs): self.obj = super().get_object(*args, **kwargs) diff --git a/taiga/projects/votes/admin.py b/taiga/projects/votes/admin.py new file mode 100644 index 00000000..4e06ae8f --- /dev/null +++ b/taiga/projects/votes/admin.py @@ -0,0 +1,25 @@ +# Copyright (C) 2014 Andrey Antukh +# Copyright (C) 2014 Jesús Espino +# Copyright (C) 2014 David Barragán +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from django.contrib import admin +from django.contrib.contenttypes.admin import GenericTabularInline + +from . import models + + +class VoteInline(GenericTabularInline): + model = models.Vote + extra = 0 diff --git a/taiga/projects/votes/models.py b/taiga/projects/votes/models.py index 7fcf857a..a1af1ff7 100644 --- a/taiga/projects/votes/models.py +++ b/taiga/projects/votes/models.py @@ -63,4 +63,4 @@ class Vote(models.Model): return None def __str__(self): - return self.user + return self.user.get_full_name() diff --git a/taiga/projects/wiki/admin.py b/taiga/projects/wiki/admin.py index cb846105..ca929fb3 100644 --- a/taiga/projects/wiki/admin.py +++ b/taiga/projects/wiki/admin.py @@ -17,6 +17,9 @@ from django.contrib import admin from taiga.projects.attachments.admin import AttachmentInline +from taiga.projects.notifications.admin import WatchedInline +from taiga.projects.votes.admin import VoteInline + from taiga.projects.wiki.models import WikiPage from . import models @@ -24,7 +27,7 @@ from . import models class WikiPageAdmin(admin.ModelAdmin): list_display = ["project", "slug", "owner"] list_display_links = list_display - # inlines = [AttachmentInline] + inlines = [WatchedInline, VoteInline] admin.site.register(models.WikiPage, WikiPageAdmin)