feat(apps): add role‑based CustomUser admin and ticketing system
- New Features * Introduce CustomUser with role field and admin integration * Add ProjectMembership model linking users to projects * Add Ticket model with status, type, creator, and project relationships * Register CustomUser and ProjectMembership in Django admin with list views * Add URLs and views for account management and ticket CRUD operations - Enhancements * Provide pagination and filtering for ticket listings * Improve admin UI with role‑specific fieldsets - Bug Fixes * Remove obsolete serializers and placeholder files
This commit is contained in:
37 files changed
+954
-126
No files matched your search
@@ -1,5 +1,11 @@
|
||||
"""generated with djinit"""
|
||||
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
from apps.activity.models import ActivityLog
|
||||
|
||||
|
||||
@admin.register(ActivityLog)
|
||||
class ActivityLogAdmin(admin.ModelAdmin):
|
||||
list_display = ["actor", "verb", "content_type", "object_id", "timestamp"]
|
||||
list_filter = ["verb", "timestamp"]
|
||||
search_fields = ["actor__username", "verb"]
|
||||
readonly_fields = ["actor", "verb", "content_type", "object_id", "timestamp"]
|
||||
+22
-3
@@ -1,5 +1,24 @@
|
||||
"""generated with djinit"""
|
||||
|
||||
from django.contrib.contenttypes.fields import GenericForeignKey
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
|
||||
class ActivityLog(models.Model):
|
||||
actor = models.ForeignKey(
|
||||
"accounts.CustomUser",
|
||||
on_delete=models.CASCADE,
|
||||
related_name="activities",
|
||||
)
|
||||
verb = models.CharField(max_length=255)
|
||||
description = models.TextField(blank=True)
|
||||
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
|
||||
object_id = models.PositiveIntegerField()
|
||||
content_object = GenericForeignKey("content_type", "object_id")
|
||||
timestamp = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = "activity logs"
|
||||
ordering = ["-timestamp"]
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.actor} {self.verb} {self.content_type} #{self.object_id}"
|
||||
@@ -1,5 +0,0 @@
|
||||
"""generated with djinit"""
|
||||
|
||||
from rest_framework import serializers
|
||||
|
||||
# Create your serializers here.
|
||||
@@ -1,7 +1,7 @@
|
||||
"""generated with djinit"""
|
||||
|
||||
from django.urls import path
|
||||
|
||||
from apps.activity.views import ActivityLogListView
|
||||
|
||||
urlpatterns = [
|
||||
# Add your URL patterns here
|
||||
]
|
||||
path("activity/", ActivityLogListView.as_view(), name="activity_list"),
|
||||
]
|
||||
+10
-3
@@ -1,5 +1,12 @@
|
||||
"""generated with djinit"""
|
||||
from django.views.generic import ListView
|
||||
|
||||
from rest_framework import viewsets
|
||||
from apps.activity.models import ActivityLog
|
||||
from apps.core.permissions import AdminRequiredMixin
|
||||
|
||||
# Create your views here.
|
||||
|
||||
class ActivityLogListView(AdminRequiredMixin, ListView):
|
||||
model = ActivityLog
|
||||
template_name = "pages/activity/activity_list.html"
|
||||
context_object_name = "activities"
|
||||
paginate_by = 50
|
||||
ordering = ["-timestamp"]
|
||||
Reference in new issue
Block a user