Skip to content

Commit

Permalink
feat: change design of admin panel
Browse files Browse the repository at this point in the history
  • Loading branch information
thenishantsapkota committed Sep 16, 2022
1 parent bc8e3f9 commit a211e38
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 12 deletions.
Binary file modified certificate/__pycache__/settings.cpython-310.pyc
Binary file not shown.
16 changes: 16 additions & 0 deletions certificate/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
# Application definition

INSTALLED_APPS = [
"jazzmin",
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
Expand Down Expand Up @@ -132,3 +133,18 @@
LOGIN_REDIRECT_URL = "/"

AUTH_USER_MODEL = "web_app.User"

JAZZMIN_SETTINGS = {
"site_title": "Character Certificate Management System",
"site_header": "CCMS",
"site_brand": "CCMS",
"copyright": "Nishant Sapkota",
"show_ui_builder": True,
"topmenu_links": [
{"name": "Home", "url": "admin:index"},
{"model": "web_app.User"},
{"app": "web_app"},
],
"changeform_format": "collapsible",
"welcome_sign": "Welcome to CCMS Admin Dashboard"
}
17 changes: 16 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Django = "^4.1.1"
Pillow = "^9.2.0"
django-versatileimagefield = "^2.2"
nepali-datetime = "^1.0.7"
django-jazzmin = "^2.5.0"


[build-system]
Expand Down
Binary file modified web_app/__pycache__/admin.cpython-310.pyc
Binary file not shown.
Binary file modified web_app/__pycache__/forms.cpython-310.pyc
Binary file not shown.
Binary file modified web_app/__pycache__/models.cpython-310.pyc
Binary file not shown.
4 changes: 4 additions & 0 deletions web_app/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from web_app.models import Certificate, User
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.contrib.auth.models import Group
from web_app.forms import UserChangeForm, UserCreationForm

# Register your models here.
Expand Down Expand Up @@ -34,8 +35,11 @@ class UserAdmin(BaseUserAdmin):
ordering = ("username",)
filter_horizontal = ()


class CertificateAdmin(admin.ModelAdmin):
pass


admin.site.unregister(Group)
admin.site.register(User, UserAdmin)
admin.site.register(Certificate, CertificateAdmin)
8 changes: 2 additions & 6 deletions web_app/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,8 @@ class ProfileForm(StylishForm):
}
),
)
institute_name = forms.CharField(
max_length=200,required=False
)
institute_address = forms.CharField(
max_length=200, required=False
)
institute_name = forms.CharField(max_length=200, required=False)
institute_address = forms.CharField(max_length=200, required=False)


class UserCreationForm(forms.ModelForm):
Expand Down
1 change: 1 addition & 0 deletions web_app/managers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.contrib.auth.base_user import BaseUserManager


class UserManager(BaseUserManager):
use_in_migrations = True

Expand Down
4 changes: 3 additions & 1 deletion web_app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class User(AbstractBaseUser, PermissionsMixin):
@property
def get_full_name(self):
return self.first_name + " " + self.last_name


class Institute(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
Expand Down Expand Up @@ -67,11 +67,13 @@ class Certificate(models.Model):
def __str__(self) -> str:
return self.registration_number


@receiver(post_save, sender=User)
def create_institute(sender, instance, created, **kwargs):
if created:
Institute.objects.create(user=instance)


# @receiver(post_save, sender=User)
# def save_institute(sender, instance, created, **kwargs):
# if created:
Expand Down
Binary file modified web_app/utils/__pycache__/util.cpython-310.pyc
Binary file not shown.
7 changes: 5 additions & 2 deletions web_app/utils/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ def create_certificate(
(poppins_bold, student_address),
],
[
(poppins_regular, f" and is a bonafide student of the academy. {'She' if gender=='female' else 'He'} passed the "),
(
poppins_regular,
f" and is a bonafide student of the academy. {'She' if gender=='female' else 'He'} passed the ",
),
],
[
(
Expand All @@ -126,7 +129,7 @@ def create_certificate(
(poppins_bold, f"{secured_gpa}."),
],
[
(poppins_regular, " According to the academy, "),
(poppins_regular, " According to record of the academy, "),
(
poppins_regular,
f"{'her' if gender=='female' else 'his'} date of birth is",
Expand Down
7 changes: 5 additions & 2 deletions web_app/views/certificate_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
class LandingView(View):
def get(self, request):
if not request.user.is_superuser:
certificate_list = Certificate.objects.filter(user_id=request.user.id).order_by("student_name")
certificate_list = Certificate.objects.filter(
user_id=request.user.id
).order_by("student_name")
else:
certificate_list = Certificate.objects.all().order_by("student_name")
paginator = Paginator(certificate_list, 5)
Expand Down Expand Up @@ -48,7 +50,8 @@ def post(self, request):
create_certificate(
request.user,
form.cleaned_data["school_name"] or "",
form.cleaned_data["school_address"] or request.user.institute.institute_address,
form.cleaned_data["school_address"]
or request.user.institute.institute_address,
form.cleaned_data["established_date"],
form.cleaned_data["gender"],
form.cleaned_data["student_name"],
Expand Down

0 comments on commit a211e38

Please sign in to comment.