development branch created to preserve working deploy project
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -5,7 +5,6 @@ from .models import DepotUser
|
||||
|
||||
@admin.register(DepotUser)
|
||||
class DepotUserAdmin(UserAdmin):
|
||||
# Add your custom fields to the fieldsets
|
||||
fieldsets = UserAdmin.fieldsets + (
|
||||
('Additional Info', {'fields': (
|
||||
'phone_number',
|
||||
@@ -16,12 +15,10 @@ class DepotUserAdmin(UserAdmin):
|
||||
)}),
|
||||
)
|
||||
|
||||
# Add fields to display in list view
|
||||
list_display = ('username', 'email', 'user_type', 'company', 'line', 'is_active', 'is_staff', 'is_superuser')
|
||||
search_fields = ('username', 'email')
|
||||
list_filter = ('user_type', 'is_active', 'is_staff', 'is_superuser')
|
||||
|
||||
# Add fields to the add form
|
||||
add_fieldsets = UserAdmin.add_fieldsets + (
|
||||
('Additional Info', {'fields': (
|
||||
'email',
|
||||
|
||||
@@ -11,6 +11,5 @@ class CompanyUserBackend(ModelBackend):
|
||||
|
||||
perms = super().get_user_permissions(user_obj, obj)
|
||||
if user_obj.company and user_obj.company.is_client:
|
||||
# Filter permissions based on client company context
|
||||
perms = {p for p in perms if p.startswith('accounts.client_')}
|
||||
return perms
|
||||
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+6
-2
@@ -1,14 +1,18 @@
|
||||
from django.contrib.auth.views import LogoutView
|
||||
from django.urls import path, include
|
||||
from django.contrib.auth import views as auth_views
|
||||
from accounts import views
|
||||
from accounts.views import CustomPasswordChangeView
|
||||
|
||||
urlpatterns = [
|
||||
path('', include([
|
||||
path('', views.UserListView.as_view(), name='user_list'),
|
||||
path('register/', views.RegisterView.as_view(), name='user_register'),
|
||||
path('login/', views.DepotLoginView.as_view(), name='login'),
|
||||
path('relogin/', auth_views.logout_then_login, name='relogin'),
|
||||
path('change-password/', views.UserChangePasswordView.as_view(), name='change_password'),
|
||||
# path('relogin/', auth_views.logout_then_login, name='relogin'),
|
||||
path('relogin/', LogoutView.as_view(next_page='login'), name='relogin'),
|
||||
path('change-password/', CustomPasswordChangeView.as_view(), name='change_password'),
|
||||
|
||||
path('<int:pk>/update/', views.UserUpdateView.as_view(), name='user_update'),
|
||||
path('<int:pk>/active/', views.UserActiveView.as_view(), name='user_active'),
|
||||
])),
|
||||
|
||||
+6
-4
@@ -1,5 +1,5 @@
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.views import LoginView
|
||||
from django.contrib.auth.views import LoginView, PasswordChangeView
|
||||
from django.http import HttpResponseForbidden, JsonResponse
|
||||
from django.shortcuts import render
|
||||
from django.urls import reverse_lazy
|
||||
@@ -192,7 +192,9 @@ class UserActiveView(LoginRequiredMixin, View):
|
||||
return JsonResponse({'success': True, 'is_active': target_user.is_active})
|
||||
|
||||
|
||||
class UserChangePasswordView(LoginRequiredMixin, View):
|
||||
class CustomPasswordChangeView(PasswordChangeView):
|
||||
template_name = 'registration/change_password.html'
|
||||
form_class = UserChangePasswordForm
|
||||
success_url = reverse_lazy('home')
|
||||
|
||||
def get_success_url(self):
|
||||
next_url = self.request.GET.get('next') or self.request.POST.get('next')
|
||||
return next_url or reverse_lazy('dashboard')
|
||||
Reference in New Issue
Block a user