Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
NishantPhour committed Oct 29, 2024
2 parents fca2f92 + 1d9fca7 commit 2df7ae1
Show file tree
Hide file tree
Showing 78 changed files with 1,460 additions and 3,265 deletions.
71 changes: 1 addition & 70 deletions mooringlicensing/admin.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
from django.contrib.admin import AdminSite
from django.contrib import admin
# from mooringlicensing.components.main import models
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import Group
from django.conf import settings

# from ledger.accounts import admin as ledger_admin
#from ledger.accounts.models import EmailUser, Document, Address, Profile
# from ledger.accounts.models import EmailUser
from ledger_api_client.ledger_models import EmailUserRO
from copy import deepcopy

admin.site.index_template = 'admin-index.html'
admin.autodiscover()
Expand All @@ -20,73 +11,13 @@ class MooringLicensingAdminSite(AdminSite):
index_title = 'Mooring Licensing Licensing'

mooringlicensing_admin_site = MooringLicensingAdminSite(name='mooringlicensingadmin')

# admin.site.unregister(EmailUser) # because this base classAdmin alsready registered in ledger.accounts.admin
# @admin.register(EmailUser)
# class EmailUserAdmin(admin.ModelAdmin):
# # 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 MooringLicensingAdmin and NOT superuser """
# fieldsets = super(UserAdmin, self).get_fieldsets(request, obj)
# #if not obj:
# # return fieldsets
#
# if request.user.is_superuser:
# return fieldsets
#
# # User is not a superuser, remove is_superuser checkbox
# 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
#
#
# @admin.register(EmailUserRO)
# class EmailUserAdmin(admin.ModelAdmin):
# list_display = (
# "email",
# "first_name",
# "last_name",
# "is_staff",
# "is_active",
# )
# ordering = ("email",)
# search_fields = ("id", "email", "first_name", "last_name")
#
# def has_change_permission(self, request, obj=None):
# if obj is None: # and obj.status > 1:
# return True
# return None
#
# def has_delete_permission(self, request, obj=None):
# return None



@admin.register(EmailUserRO)
class EmailUserROAdmin(admin.ModelAdmin):
list_display = ('email','first_name','last_name','is_staff','is_active',)
ordering = ('email',)
search_fields = ('id','email','first_name','last_name')
readonly_fields = ['email','first_name','last_name','is_staff','is_active','user_permissions']

# def has_change_permission(self, request, obj=None):
# if obj is None: # and obj.status > 1:
# return True
# return None
def has_delete_permission(self, request, obj=None):
return False

# def get_readonly_fields(self, request, obj=None):
# if 'edit' not in request.GET:
# return self.readonly_fields
# else:
# return self.readonly_fields
1 change: 0 additions & 1 deletion mooringlicensing/components/approvals/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class ApprovalAdmin(admin.ModelAdmin):
'start_date',
'expiry_date',
'current_proposal',
'replaced_by',
'applicant',
]
search_fields = ['lodgement_number',]
Expand Down
Loading

0 comments on commit 2df7ae1

Please sign in to comment.