summaryrefslogtreecommitdiffstats
path: root/patchwork/admin.py
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2015-05-24 16:57:33 +0800
committerJeremy Kerr <jk@ozlabs.org>2015-05-27 10:26:41 +0800
commitad2762cf775a8dde508de47164d6429f3fd724f1 (patch)
treee63015a468cfe32c961908f0338d423227799815 /patchwork/admin.py
parentf09e982f58384946111d4157fd2b7c2b31b78612 (diff)
downloadpatchwork-ad2762cf775a8dde508de47164d6429f3fd724f1.tar.bz2
patchwork-ad2762cf775a8dde508de47164d6429f3fd724f1.tar.xz
Move to a more recent django project structure
This change updates patchwor to the newer project struture: we've moved the actual application out of the apps/ directory, and the patchwork-specific templates to under the patchwork application. This gives us the manage.py script in the top-level now. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'patchwork/admin.py')
-rw-r--r--patchwork/admin.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/patchwork/admin.py b/patchwork/admin.py
new file mode 100644
index 0000000..5297903
--- /dev/null
+++ b/patchwork/admin.py
@@ -0,0 +1,50 @@
+from django.contrib import admin
+from patchwork.models import Project, Person, UserProfile, State, Patch, \
+ Comment, Bundle
+
+class ProjectAdmin(admin.ModelAdmin):
+ list_display = ('name', 'linkname','listid', 'listemail')
+admin.site.register(Project, ProjectAdmin)
+
+class PersonAdmin(admin.ModelAdmin):
+ list_display = ('__unicode__', 'has_account')
+ search_fields = ('name', 'email')
+ def has_account(self, person):
+ return bool(person.user)
+ has_account.boolean = True
+ has_account.admin_order_field = 'user'
+ has_account.short_description = 'Account'
+admin.site.register(Person, PersonAdmin)
+
+class UserProfileAdmin(admin.ModelAdmin):
+ search_fields = ('user__username', 'user__first_name', 'user__last_name')
+admin.site.register(UserProfile, UserProfileAdmin)
+
+class StateAdmin(admin.ModelAdmin):
+ list_display = ('name', 'action_required')
+admin.site.register(State, StateAdmin)
+
+class PatchAdmin(admin.ModelAdmin):
+ list_display = ('name', 'submitter', 'project', 'state', 'date',
+ 'archived', 'is_pull_request')
+ list_filter = ('project', 'state', 'archived')
+ search_fields = ('name', 'submitter__name', 'submitter__email')
+ date_hierarchy = 'date'
+ def is_pull_request(self, patch):
+ return bool(patch.pull_url)
+ is_pull_request.boolean = True
+ is_pull_request.admin_order_field = 'pull_url'
+ is_pull_request.short_description = 'Pull'
+admin.site.register(Patch, PatchAdmin)
+
+class CommentAdmin(admin.ModelAdmin):
+ list_display = ('patch', 'submitter', 'date')
+ search_fields = ('patch__name', 'submitter__name', 'submitter__email')
+ date_hierarchy = 'date'
+admin.site.register(Comment, CommentAdmin)
+
+class BundleAdmin(admin.ModelAdmin):
+ list_display = ('name', 'owner', 'project', 'public')
+ list_filter = ('public', 'project')
+ search_fields = ('name', 'owner')
+admin.site.register(Bundle, BundleAdmin)