Add IntelliJ IDEA project configuration files
This commit adds IntelliJ IDEA-specific configuration files for the project, including module setup, version control integration, inspection profiles, and workspace settings. These files facilitate development environment configuration for contributors using IntelliJ IDEA.
This commit is contained in:
@@ -1,7 +1,47 @@
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.forms import AuthenticationForm
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.forms import CharField
|
||||
from django.forms.models import ModelForm
|
||||
from django.forms.widgets import PasswordInput
|
||||
|
||||
|
||||
class LoginForm(AuthenticationForm):
|
||||
field_order = ['username', 'password']
|
||||
class Meta:
|
||||
model = get_user_model()
|
||||
|
||||
|
||||
class RegisterForm(ModelForm):
|
||||
password1 = CharField(label='Password', widget=PasswordInput)
|
||||
password2 = CharField(label='Confirm Password', widget=PasswordInput)
|
||||
|
||||
field_order = ['username', 'email', 'password1', 'password2', 'phone_number', 'line', 'company_permissions']
|
||||
|
||||
|
||||
class Meta:
|
||||
model = get_user_model()
|
||||
fields = ['username', 'email', 'password1', 'password2', 'phone_number', 'line', 'company_permissions']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields['password1'].widget.attrs.update({'autocomplete': 'new-password'})
|
||||
self.fields['password2'].widget.attrs.update({'autocomplete': 'new-password'})
|
||||
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super().clean()
|
||||
password1 = cleaned_data.get('password1')
|
||||
password2 = cleaned_data.get('password2')
|
||||
|
||||
if password1 and password2 and password1 != password2:
|
||||
raise ValidationError("Passwords don't match")
|
||||
return cleaned_data
|
||||
|
||||
def save(self, commit=True):
|
||||
user = super().save(commit=False)
|
||||
user.set_password(self.cleaned_data['password1'])
|
||||
if commit:
|
||||
user.save()
|
||||
return user
|
||||
|
||||
|
||||
+5
-1
@@ -2,6 +2,9 @@ from django.contrib.auth.models import AbstractUser
|
||||
from django.db import models
|
||||
|
||||
class ClientPermission(models.Model):
|
||||
codename = models.CharField(max_length=100, default='')
|
||||
name = models.CharField(max_length=255, default='')
|
||||
|
||||
class Meta:
|
||||
managed = True
|
||||
default_permissions = ()
|
||||
@@ -10,7 +13,8 @@ class ClientPermission(models.Model):
|
||||
('can_view_bookings', 'Can view bookings'),
|
||||
('can_manage_company_users', 'Can manage company users'),
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class DepotUser(AbstractUser):
|
||||
|
||||
|
||||
@@ -5,4 +5,5 @@ from accounts import views
|
||||
urlpatterns = [
|
||||
path('login/', views.DepotLoginView.as_view(), name='login'),
|
||||
path('relogin/', auth_views.logout_then_login, name='relogin'),
|
||||
path('register/', views.RegisterView.as_view(), name='register'),
|
||||
]
|
||||
+26
-2
@@ -1,9 +1,10 @@
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.views import LoginView
|
||||
from django.shortcuts import render
|
||||
from django.urls import reverse_lazy
|
||||
from django.views.generic import TemplateView, FormView
|
||||
from django.views.generic import TemplateView, FormView, ListView, UpdateView
|
||||
|
||||
from accounts.forms import LoginForm
|
||||
from accounts.forms import LoginForm, RegisterForm
|
||||
|
||||
|
||||
# Create your views here.
|
||||
@@ -14,4 +15,27 @@ class DepotLoginView(LoginView):
|
||||
next_page = reverse_lazy('dashboard')
|
||||
|
||||
|
||||
class RegisterView(FormView):
|
||||
template_name = 'registration/register.html'
|
||||
form_class = RegisterForm
|
||||
# model = get_user_model()
|
||||
success_url = reverse_lazy('dashboard')
|
||||
|
||||
def form_valid(self, form):
|
||||
# Create user from form data
|
||||
user = form.save(commit=False)
|
||||
# user.set_password(form.cleaned_data['password'])
|
||||
user.save()
|
||||
return super().form_valid(form)
|
||||
|
||||
class UserListView(ListView):
|
||||
template_name = 'registration/register.html'
|
||||
# form_class = RegisterForm
|
||||
model = get_user_model()
|
||||
success_url = reverse_lazy('dashboard')
|
||||
|
||||
class UserEditView(UpdateView):
|
||||
template_name = 'registration/register.html'
|
||||
form_class = RegisterForm
|
||||
model = get_user_model()
|
||||
success_url = reverse_lazy('dashboard')
|
||||
|
||||
Reference in New Issue
Block a user