Skip to content

Commit

Permalink
chore: non-related - make admin table for user and user-operator pret…
Browse files Browse the repository at this point in the history
…tier

Signed-off-by: SeSo <[email protected]>
  • Loading branch information
Sepehr-Sobhani committed Nov 19, 2024
1 parent 31701f9 commit 80ef128
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions bc_obps/registration/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@

admin.site.register(AppRole)
admin.site.register(NaicsCode)
admin.site.register(User)
admin.site.register(Operator)
admin.site.register(UserOperator)
admin.site.register(ParentOperator)
admin.site.register(RegulatedProduct)
admin.site.register(Activity)
Expand Down Expand Up @@ -103,3 +101,27 @@ class DocumentAdmin(admin.ModelAdmin):
@staticmethod
def type_name(obj: Document) -> str:
return obj.type.name


@admin.register(User)
class UserAdmin(admin.ModelAdmin):
list_display = ('user_guid', 'first_name', 'last_name', 'email', 'position_title', 'role')
search_fields = ('user_guid', 'first_name', 'last_name')

@staticmethod
def role(obj: User) -> str:
return obj.app_role.role_name


@admin.register(UserOperator)
class UserOperatorAdmin(admin.ModelAdmin):
list_display = ('id', 'user_full_name', 'operator_legal_name', 'role', 'status')
ordering = ('-created_at',)

@staticmethod
def user_full_name(obj: UserOperator) -> str:
return obj.user.first_name + ' ' + obj.user.last_name

@staticmethod
def operator_legal_name(obj: UserOperator) -> str:
return obj.operator.legal_name

0 comments on commit 80ef128

Please sign in to comment.