From 9feda5f948958ebc88a818eaf2a86220e750aad8 Mon Sep 17 00:00:00 2001 From: Kasper Brandt Date: Thu, 19 Feb 2015 14:16:59 +0100 Subject: [PATCH] [#1104] Fixed user, organisation and update admin --- akvo/rsr/admin.py | 56 ++----------------- .../admin/rsr/organisation/change_form.html | 8 +++ 2 files changed, 13 insertions(+), 51 deletions(-) diff --git a/akvo/rsr/admin.py b/akvo/rsr/admin.py index 5e0be0fc21..bf597dea55 100644 --- a/akvo/rsr/admin.py +++ b/akvo/rsr/admin.py @@ -28,20 +28,12 @@ from akvo.rsr.fields import ValidXMLCharField from rules.contrib.admin import ObjectPermissionsModelAdmin -from nested_inlines.admin import NestedModelAdmin, NestedStackedInline, NestedTabularInline +from nested_inlines.admin import NestedModelAdmin, NestedStackedInline NON_FIELD_ERRORS = '__all__' csrf_protect_m = method_decorator(csrf_protect) -class PermissionAdmin(admin.ModelAdmin): - list_display = (u'__unicode__', u'content_type', ) - list_filter = (u'content_type', ) - ordering = (u'content_type', ) - -admin.site.register(get_model('auth', 'permission'), PermissionAdmin) - - class CountryAdmin(admin.ModelAdmin): list_display = (u'name', u'iso_code', u'continent', u'continent_code', ) list_filter = (u'continent', ) @@ -58,6 +50,7 @@ def get_readonly_fields(self, request, obj=None): class OrganisationLocationInline(admin.StackedInline): model = get_model('rsr', 'organisationlocation') extra = 0 + fields = ('id', 'latitude', 'longitude', 'city', 'state', 'address_1', 'address_2', 'postcode', 'country') class InternalOrganisationIDAdmin(admin.ModelAdmin): @@ -209,39 +202,11 @@ def get_queryset(self, request): admin.site.register(get_model('rsr', 'publishingstatus'), PublishingStatusAdmin) -class FocusAreaAdmin(admin.ModelAdmin): - model = get_model('rsr', 'FocusArea') - list_display = ('name', 'slug', 'image',) - -admin.site.register(get_model('rsr', 'FocusArea'), FocusAreaAdmin) - - class BenchmarknameInline(admin.TabularInline): model = get_model('rsr', 'Category').benchmarknames.through extra = 3 -class CategoryAdmin(admin.ModelAdmin): - model = get_model('rsr', 'Category') - list_display = ('name', 'focus_areas_html', 'category_benchmarks_html', ) - -admin.site.register(get_model('rsr', 'Category'), CategoryAdmin) - - -class BenchmarknameAdmin(admin.ModelAdmin): - model = get_model('rsr', 'Benchmarkname') - list_display = ('name', 'order',) - -admin.site.register(get_model('rsr', 'Benchmarkname'), BenchmarknameAdmin) - - -class MiniCMSAdmin(admin.ModelAdmin): - model = get_model('rsr', 'MiniCMS') - list_display = ('__unicode__', 'active', ) - -admin.site.register(get_model('rsr', 'MiniCMS'), MiniCMSAdmin) - - class BenchmarkInline(NestedStackedInline): model = get_model('rsr', 'benchmark') # only show the value, category and benchmark are not to be edited here @@ -839,9 +804,9 @@ def add_view(self, request, form_url='', extra_context=None): admin.site.register(get_model('rsr', 'project'), ProjectAdmin) -class ApiKeyInline(admin.TabularInline): +class ApiKeyInline(admin.StackedInline): model = get_model('tastypie', 'apikey') - fields = ('key',) + fields = ('id', 'key',) readonly_fields = ('key',) def has_delete_permission(self, request, obj=None, **kwargs): @@ -905,6 +870,7 @@ class ProjectCommentAdmin(admin.ModelAdmin): class ProjectUpdateLocationInline(admin.StackedInline): model = get_model('rsr', 'projectupdatelocation') extra = 0 + fields = ('id', 'latitude', 'longitude', 'city', 'state', 'address_1', 'address_2', 'postcode', 'country') class ProjectUpdateAdmin(TimestampsAdminDisplayMixin, AdminVideoMixin, admin.ModelAdmin): @@ -980,18 +946,6 @@ def void_invoices(self, request, queryset): admin.site.register(get_model('rsr', 'invoice'), InvoiceAdmin) -class PayPalGatewayAdmin(admin.ModelAdmin): - list_display = ('name', 'account_email', 'description', 'currency', 'locale', 'notification_email') - -admin.site.register(get_model('rsr', 'paypalgateway'), PayPalGatewayAdmin) - - -class MollieGatewayAdmin(admin.ModelAdmin): - list_display = ('name', 'partner_id', 'description', 'currency', 'notification_email') - -admin.site.register(get_model('rsr', 'molliegateway'), MollieGatewayAdmin) - - class PaymentGatewaySelectorAdmin(admin.ModelAdmin): list_display = ('__unicode__', 'paypal_gateway', 'mollie_gateway') list_filter = ('paypal_gateway', 'mollie_gateway') diff --git a/akvo/templates/admin/rsr/organisation/change_form.html b/akvo/templates/admin/rsr/organisation/change_form.html index 8d2421e523..8da3ae78fb 100644 --- a/akvo/templates/admin/rsr/organisation/change_form.html +++ b/akvo/templates/admin/rsr/organisation/change_form.html @@ -1,6 +1,14 @@ {% extends "admin/change_form.html" %} {% load i18n admin_modify %} +{% block extrastyle %} + {{block.super}} + +{% endblock %} {% block pretitle %} {{ block.super }}