diff --git a/.gitignore b/.gitignore index dc5782d..2f3533c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ *.swp **/__pycache__ db.sqlite3 +*.sqlite3 media # Backup files # diff --git a/access_ctrl/admin.py b/access_ctrl/admin.py index 6ecdf16..e5595c6 100644 --- a/access_ctrl/admin.py +++ b/access_ctrl/admin.py @@ -1,8 +1,36 @@ from django.contrib import admin from .models import * +from django.contrib.auth.models import User +from django.contrib.auth.admin import UserAdmin as BaseUserAdmin # Register your models here. +class CustomUserAdmin(BaseUserAdmin): + # Remove 'groups' and 'user_permissions' from the fieldsets + fieldsets = ( + (None, {'fields': ('username', 'password')}), + ('Personal info', {'fields': ('first_name', 'last_name', 'email')}), + ('Important dates', {'fields': ('last_login', 'date_joined')}), + ('Status', {'fields': ('is_active', 'is_staff', 'is_superuser', 'user_permissions')}), + ) + + # Remove them from add_fieldsets too (user creation form) + add_fieldsets = ( + (None, { + 'classes': ('wide',), + 'fields': ('username', 'password1', 'password2'), + }), + ) + + # Hide columns in the list display if you don’t want them there + def get_fieldsets(self, request, obj=None): + return super().get_fieldsets(request, obj) + +# Unregister the original UserAdmin +admin.site.unregister(User) +# Register our custom one +admin.site.register(User, CustomUserAdmin) + # ----------------------------- # Permission Admin # ----------------------------- @@ -27,7 +55,7 @@ class RoleAdmin(admin.ModelAdmin): @admin.register(RolePermission) class RolePermissionAdmin(admin.ModelAdmin): list_display = ("role",) - filter_horizontal = ("permissions",) # Makes ManyToMany easy to edit + filter_horizontal = ("permissions",) search_fields = ("role__name",) # ----------------------------- @@ -36,7 +64,7 @@ class RolePermissionAdmin(admin.ModelAdmin): @admin.register(UserPermission) class UserPermissionAdmin(admin.ModelAdmin): list_display = ("user",) - filter_horizontal = ("permissions",) # Makes ManyToMany easy to edit + filter_horizontal = ("permissions",) search_fields = ("user__username",) # ----------------------------- diff --git a/access_ctrl/apps.py b/access_ctrl/apps.py index eef60d2..75b33d8 100644 --- a/access_ctrl/apps.py +++ b/access_ctrl/apps.py @@ -1,6 +1,22 @@ from django.apps import AppConfig +from django.contrib.auth.apps import AuthConfig as BaseAuthConfig class AccessCtrlConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'access_ctrl' + +class CustomAuthConfig(BaseAuthConfig): + verbose_name = "User Management" + + def ready(self): + super().ready() # registers User & Group + from django.contrib import admin + from django.contrib.auth.models import Group + + # Unregister Group after it's registered + try: + admin.site.unregister(Group) + except admin.sites.NotRegistered: + pass + diff --git a/access_ctrl/utils.py b/access_ctrl/utils.py index 790ea4e..64c3a7e 100644 --- a/access_ctrl/utils.py +++ b/access_ctrl/utils.py @@ -7,6 +7,9 @@ def user_has_permission(user, codename, obj=None): """ Check if a user has a permission, directly, via role, or object-level. """ + if user.is_superuser: + return True + try: perm = Perms.objects.get(codename=codename) except Perms.DoesNotExist: diff --git a/core/admin.py b/core/admin.py index 62bc1f2..dad469e 100644 --- a/core/admin.py +++ b/core/admin.py @@ -2,6 +2,7 @@ from core.models import Token_Session, Registered_Participant, Token_Participant # Register your models here. + @admin.register(Token_Session) class SessionAdmin(admin.ModelAdmin): diff --git a/core/static/img/Footer.png b/core/static/img/Footer.png new file mode 100644 index 0000000..36c179e Binary files /dev/null and b/core/static/img/Footer.png differ diff --git a/core/static/img/Footer1.png b/core/static/img/Footer1.png new file mode 100644 index 0000000..5132d43 Binary files /dev/null and b/core/static/img/Footer1.png differ diff --git a/core/static/img/Footer2.png b/core/static/img/Footer2.png new file mode 100644 index 0000000..e0bf3a4 Binary files /dev/null and b/core/static/img/Footer2.png differ diff --git a/core/static/img/Stepclosed.png b/core/static/img/Stepclosed.png new file mode 100644 index 0000000..1cdd987 Binary files /dev/null and b/core/static/img/Stepclosed.png differ diff --git a/core/templates/coordinator_dashboard.html b/core/templates/coordinator_dashboard.html index 3b25c2f..b77f700 100644 --- a/core/templates/coordinator_dashboard.html +++ b/core/templates/coordinator_dashboard.html @@ -246,17 +246,21 @@ justify-content: space-between; } .footer { + display: flex; + margin: auto; + justify-content: center; + gap: 250px; background-color: #f8f8f8; /* color: white; */ position: fixed; bottom: 0; width: 100%; text-align: center; - padding: 10px 0; + /* padding: 10px 0; */ /* z-index: -1; */ } .footer img { - height: 68px; + height: 90px; } .count { font-size: 1.5rem; @@ -485,8 +489,12 @@ td { padding: 5px; } + .footer{ + gap: 40px; + } .footer img { - height: 27px; + height: 30px; + /* scale: 1.3; */ } .count { font-size: 1rem; @@ -529,11 +537,11 @@
- {% if request.user|has_perm:"update_session" %} + {% if has_perm.update_session %} {% endif %} - Registration Form - {% if request.user|has_perm:"scan_session" %} + Registration Form + {% if has_perm.scan_session %} {% endif %}
@@ -611,10 +619,10 @@ Name University Tshirt Size - Role + {% comment %} Role {% endcomment %} Contact {% for session in token_sessions_all %} - {% if request.user|has_perm:"scan_any_session" or session.is_active %} + {% if has_perm.scan_any_session or session.is_active %} {{session.session_name}} {% endif %} {% endfor %} @@ -628,10 +636,10 @@ {{participant.name}} {{participant.university}} {{participant.t_shirt_size}} - {{participant.role}} + {% comment %} {{participant.role}} {% endcomment %} {{participant.contact_no}} {% for session in token_sessions_all %} - {% if request.user|has_perm:"scan_any_session" or session.is_active %} + {% if has_perm.scan_any_session or session.is_active %} @@ -654,7 +662,8 @@
Select a Session
- {% if request.user|has_perm:"update_session" %} + {% if has_perm.update_session %}