Skip to content

Commit 87ea5a1

Browse files
Merge pull request #1 from app-generator/argon
project completed
2 parents 2721e50 + 0823625 commit 87ea5a1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+5409
-2576
lines changed

home/admin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

home/apps.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class HomeConfig(AppConfig):
5+
default_auto_field = "django.db.models.BigAutoField"
6+
name = "home"

home/forms.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
from django import forms
2+
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm, PasswordChangeForm, UsernameField, PasswordResetForm, SetPasswordForm
3+
from django.contrib.auth.models import User
4+
from django.utils.translation import gettext_lazy as _
5+
6+
7+
class RegistrationForm(UserCreationForm):
8+
password1 = forms.CharField(
9+
label=_("Password"),
10+
widget=forms.PasswordInput(attrs={'class': 'text-sm focus:shadow-soft-primary-outline leading-5.6 ease-soft block w-full appearance-none rounded-lg border border-solid border-gray-300 bg-white bg-clip-padding py-2 px-3 font-normal text-gray-700 transition-all focus:border-fuchsia-300 focus:bg-white focus:text-gray-700 focus:outline-none focus:transition-shadow', 'placeholder': 'Password'}),
11+
)
12+
password2 = forms.CharField(
13+
label=_("Password Confirmation"),
14+
widget=forms.PasswordInput(attrs={'class': 'text-sm focus:shadow-soft-primary-outline leading-5.6 ease-soft block w-full appearance-none rounded-lg border border-solid border-gray-300 bg-white bg-clip-padding py-2 px-3 font-normal text-gray-700 transition-all focus:border-fuchsia-300 focus:bg-white focus:text-gray-700 focus:outline-none focus:transition-shadow', 'placeholder': 'Password Confirmation'}),
15+
)
16+
17+
class Meta:
18+
model = User
19+
fields = ('username', 'email', )
20+
21+
widgets = {
22+
'username': forms.TextInput(attrs={
23+
'class': 'text-sm focus:shadow-soft-primary-outline leading-5.6 ease-soft block w-full appearance-none rounded-lg border border-solid border-gray-300 bg-white bg-clip-padding py-2 px-3 font-normal text-gray-700 transition-all focus:border-fuchsia-300 focus:bg-white focus:text-gray-700 focus:outline-none focus:transition-shadow',
24+
'placeholder': 'Username'
25+
}),
26+
'email': forms.EmailInput(attrs={
27+
'class': 'text-sm focus:shadow-soft-primary-outline leading-5.6 ease-soft block w-full appearance-none rounded-lg border border-solid border-gray-300 bg-white bg-clip-padding py-2 px-3 font-normal text-gray-700 transition-all focus:border-fuchsia-300 focus:bg-white focus:text-gray-700 focus:outline-none focus:transition-shadow',
28+
'placeholder': 'Email'
29+
})
30+
}
31+
32+
33+
class LoginForm(AuthenticationForm):
34+
username = UsernameField(widget=forms.TextInput(attrs={"class": "focus:shadow-soft-primary-outline text-sm leading-5.6 ease-soft block w-full appearance-none rounded-lg border border-solid border-gray-300 bg-white bg-clip-padding px-3 py-2 font-normal text-gray-700 transition-all focus:border-fuchsia-300 focus:outline-none focus:transition-shadow", "placeholder": "Username"}))
35+
password = forms.CharField(
36+
label=_("Password"),
37+
strip=False,
38+
widget=forms.PasswordInput(attrs={"class": "focus:shadow-soft-primary-outline text-sm leading-5.6 ease-soft block w-full appearance-none rounded-lg border border-solid border-gray-300 bg-white bg-clip-padding px-3 py-2 font-normal text-gray-700 transition-all focus:border-fuchsia-300 focus:outline-none focus:transition-shadow", "placeholder": "Password"}),
39+
)
40+
41+
class UserPasswordResetForm(PasswordResetForm):
42+
email = forms.EmailField(widget=forms.EmailInput(attrs={
43+
'class': 'focus:shadow-soft-primary-outline text-sm leading-5.6 ease-soft block w-full appearance-none rounded-lg border border-solid border-gray-300 bg-white bg-clip-padding px-3 py-2 font-normal text-gray-700 transition-all focus:border-fuchsia-300 focus:outline-none focus:transition-shadow',
44+
'placeholder': 'Email'
45+
}))
46+
47+
class UserSetPasswordForm(SetPasswordForm):
48+
new_password1 = forms.CharField(max_length=50, widget=forms.PasswordInput(attrs={
49+
'class': 'focus:shadow-soft-primary-outline text-sm leading-5.6 ease-soft block w-full appearance-none rounded-lg border border-solid border-gray-300 bg-white bg-clip-padding px-3 py-2 font-normal text-gray-700 transition-all focus:border-fuchsia-300 focus:outline-none focus:transition-shadow', 'placeholder': 'New Password'
50+
}), label="New Password")
51+
new_password2 = forms.CharField(max_length=50, widget=forms.PasswordInput(attrs={
52+
'class': 'focus:shadow-soft-primary-outline text-sm leading-5.6 ease-soft block w-full appearance-none rounded-lg border border-solid border-gray-300 bg-white bg-clip-padding px-3 py-2 font-normal text-gray-700 transition-all focus:border-fuchsia-300 focus:outline-none focus:transition-shadow', 'placeholder': 'Confirm New Password'
53+
}), label="Confirm New Password")
54+
55+
56+
class UserPasswordChangeForm(PasswordChangeForm):
57+
old_password = forms.CharField(max_length=50, widget=forms.PasswordInput(attrs={
58+
'class': 'focus:shadow-soft-primary-outline text-sm leading-5.6 ease-soft block w-full appearance-none rounded-lg border border-solid border-gray-300 bg-white bg-clip-padding px-3 py-2 font-normal text-gray-700 transition-all focus:border-fuchsia-300 focus:outline-none focus:transition-shadow', 'placeholder': 'Old Password'
59+
}), label='Old Password')
60+
new_password1 = forms.CharField(max_length=50, widget=forms.PasswordInput(attrs={
61+
'class': 'focus:shadow-soft-primary-outline text-sm leading-5.6 ease-soft block w-full appearance-none rounded-lg border border-solid border-gray-300 bg-white bg-clip-padding px-3 py-2 font-normal text-gray-700 transition-all focus:border-fuchsia-300 focus:outline-none focus:transition-shadow', 'placeholder': 'New Password'
62+
}), label="New Password")
63+
new_password2 = forms.CharField(max_length=50, widget=forms.PasswordInput(attrs={
64+
'class': 'focus:shadow-soft-primary-outline text-sm leading-5.6 ease-soft block w-full appearance-none rounded-lg border border-solid border-gray-300 bg-white bg-clip-padding px-3 py-2 font-normal text-gray-700 transition-all focus:border-fuchsia-300 focus:outline-none focus:transition-shadow', 'placeholder': 'Confirm New Password'
65+
}), label="Confirm New Password")

home/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.db import models
2+
3+
# Create your models here.

home/templatetags/admin_argon.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import re
2+
from django import template
3+
from django.utils.html import format_html
4+
from home.utils import get_menu_items
5+
from django.utils.safestring import mark_safe
6+
from django.contrib.admin.views.main import (PAGE_VAR)
7+
8+
register = template.Library()
9+
assignment_tag = register.assignment_tag if hasattr(register, 'assignment_tag') else register.simple_tag
10+
11+
12+
@register.filter
13+
def clean_text(value):
14+
res = value.replace('\n', ' ')
15+
return res
16+
17+
18+
@register.filter
19+
def checkbox(value):
20+
res = re.sub(r"</?(?i:td)(.|\n)*?>", "", value)
21+
return res
22+
23+
24+
@assignment_tag(takes_context=True)
25+
def admin_get_menu(context):
26+
return get_menu_items(context)
27+
28+
29+
@assignment_tag(takes_context=True)
30+
def get_direction(context):
31+
res = {
32+
'panel': 'text-left',
33+
'notify': 'right',
34+
'float': 'float-right',
35+
'reverse_panel': 'text-right',
36+
'nav': 'ml-auto'
37+
}
38+
39+
if context.get('LANGUAGE_BIDI'):
40+
res['panel'] = 'text-right'
41+
res['notify'] = 'left'
42+
res['float'] = ''
43+
res['reverse_panel'] = 'text-left'
44+
res['nav'] = 'mr-auto'
45+
return res
46+
47+
48+
@assignment_tag(takes_context=True)
49+
def get_admin_setting(context):
50+
# user = context.get('request').user
51+
# admin_black_setting = user.admin_black_setting if hasattr(user, 'admin_black_setting') else None
52+
res = {
53+
# 'sidebar_background': admin_black_setting.sidebar_background if admin_black_setting else 'primary',
54+
# 'dark_mode': admin_black_setting.dark_mode if admin_black_setting else True,
55+
# 'input_bg_color': '#ffffff' if admin_black_setting and not admin_black_setting.dark_mode else '#27293c'
56+
}
57+
58+
return res
59+
60+
61+
@register.simple_tag
62+
def paginator_number(cl, i):
63+
"""
64+
Generate an individual page index link in a paginated list.
65+
"""
66+
if i == cl.paginator.ELLIPSIS:
67+
return format_html('{} ', cl.paginator.ELLIPSIS)
68+
elif i == cl.page_num:
69+
return format_html('<a href="" class="page-link">{}</a> ', i)
70+
else:
71+
return format_html(
72+
'<a href="{}" class="page-link {}">{}</a> ',
73+
cl.get_query_string({PAGE_VAR: i}),
74+
mark_safe('end' if i == cl.paginator.num_pages else ''),
75+
i,
76+
)
77+
78+
79+
@register.filter
80+
def sum_number(value, number):
81+
return value + number
82+
83+
84+
@register.filter
85+
def neg_num(value, number):
86+
return value - number

home/templatetags/replace_value.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django import template
2+
3+
register = template.Library()
4+
5+
@register.filter(name="replace_value")
6+
def replace_value(value, arg):
7+
return value.replace(arg, " ").title()

home/tests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

home/urls.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from django.urls import path
2+
from django.contrib.auth import views as auth_views
3+
4+
from . import views
5+
6+
urlpatterns = [
7+
path('', views.index, name='index'),
8+
path('tables/', views.tables, name='tables'),
9+
path('billing/', views.billing, name='billing'),
10+
path('vr/', views.vr, name='vr'),
11+
path('rtl/', views.rtl, name='rtl'),
12+
path('profile/', views.profile, name='profile'),
13+
14+
# Authentication
15+
path('accounts/login/', views.UserLoginView.as_view(), name='login'),
16+
path('accounts/logout/', views.logout_view, name='logout'),
17+
path('accounts/register/', views.UserRegistration.as_view(), name='register'),
18+
path('accounts/password-change/', views.UserPasswordChangeView.as_view(), name='password_change'),
19+
path('accounts/password-change-done/', auth_views.PasswordChangeDoneView.as_view(
20+
template_name='accounts/password_change_done.html'
21+
), name="password_change_done"),
22+
path('accounts/password-reset/', views.UserPasswordResetView.as_view(), name='password_reset'),
23+
path('accounts/password-reset-confirm/<uidb64>/<token>/',
24+
views.UserPasswordResetConfirmView.as_view(), name='password_reset_confirm'),
25+
path('accounts/password-reset-done/', auth_views.PasswordResetDoneView.as_view(
26+
template_name='accounts/password_reset_done.html'
27+
), name='password_reset_done'),
28+
path('accounts/password-reset-complete/', auth_views.PasswordResetCompleteView.as_view(
29+
template_name='accounts/password_reset_complete.html'
30+
), name='password_reset_complete'),
31+
]

0 commit comments

Comments
 (0)