Skip to content

Commit

Permalink
Merge pull request #1141 from akvo/1104_admin_break
Browse files Browse the repository at this point in the history
[#1104] Fixed user, organisation and update admin
  • Loading branch information
kardan committed Feb 19, 2015
2 parents 69b9314 + 9feda5f commit ae1535e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 51 deletions.
56 changes: 5 additions & 51 deletions akvo/rsr/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', )
Expand All @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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')
Expand Down
8 changes: 8 additions & 0 deletions akvo/templates/admin/rsr/organisation/change_form.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
{% extends "admin/change_form.html" %}
{% load i18n admin_modify %}

{% block extrastyle %}
{{block.super}}
<style>
.field-id {
display: none;
}
</style>
{% endblock %}

{% block pretitle %}
{{ block.super }}
Expand Down

0 comments on commit ae1535e

Please sign in to comment.