-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1,612 changed files
with
86,048 additions
and
1,300 deletions.
There are no files selected for viewing
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
default_app_config = 'commercialoperator.apps.CommercialOperatorConfig' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from django.contrib.admin import AdminSite | ||
from django.contrib import admin | ||
from django.contrib.auth.admin import UserAdmin | ||
from django.contrib.auth.models import Group | ||
|
||
from ledger.accounts import admin as ledger_admin | ||
#from ledger.accounts.models import EmailUser, Document, Address, Profile | ||
from ledger.accounts.models import EmailUser | ||
from copy import deepcopy | ||
|
||
|
||
class CommercialOperatorAdminSite(AdminSite): | ||
site_header = 'Commercial Operator Administration' | ||
site_title = 'Commercial Operator Licensing' | ||
index_title = 'Commercial Operator Licensing' | ||
|
||
commercialoperator_admin_site = CommercialOperatorAdminSite(name='commercialoperatoradmin') | ||
|
||
admin.site.unregister(EmailUser) # because this base classAdmin alsready registered in ledger.accounts.admin | ||
@admin.register(EmailUser) | ||
class EmailUserAdmin(ledger_admin.EmailUserAdmin): | ||
""" | ||
Overriding the EmailUserAdmin from ledger.accounts.admin, to remove is_superuser checkbox field on Admin page | ||
""" | ||
|
||
def get_fieldsets(self, request, obj=None): | ||
""" Remove the is_superuser checkbox from the Admin page, if user is CommercialOperatorAdmin and NOT superuser """ | ||
fieldsets = super(UserAdmin, self).get_fieldsets(request, obj) | ||
if not obj: | ||
return fieldsets | ||
|
||
if request.user.is_superuser: | ||
return fieldsets | ||
|
||
group = Group.objects.filter(name='CommercialOperator Admin') | ||
if group and group[0] in request.user.groups.all(): | ||
fieldsets = deepcopy(fieldsets) | ||
for fieldset in fieldsets: | ||
if 'is_superuser' in fieldset[1]['fields']: | ||
if type(fieldset[1]['fields']) == tuple : | ||
fieldset[1]['fields'] = list(fieldset[1]['fields']) | ||
fieldset[1]['fields'].remove('is_superuser') | ||
break | ||
|
||
return fieldsets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from __future__ import unicode_literals | ||
from django.conf import settings | ||
|
||
from django.apps import AppConfig | ||
|
||
class CommercialOperatorConfig(AppConfig): | ||
name = 'commercialoperator' | ||
verbose_name = settings.SYSTEM_NAME | ||
|
||
run_once = False | ||
def ready(self): | ||
if not self.run_once: | ||
from commercialoperator.components.organisations import signals | ||
from commercialoperator.components.proposals import signals | ||
|
||
self.run_once = True |
Empty file.
Empty file.
Empty file.
Oops, something went wrong.