mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-09 12:30:15 +02:00
[CHANGE] Switch to Django Solo
This commit is contained in:
parent
ecc9e68330
commit
e0d76dc268
@ -2,16 +2,16 @@
|
||||
Admin classes for custom_css app
|
||||
"""
|
||||
|
||||
# Django
|
||||
from django.contrib import admin
|
||||
|
||||
# Django Solos
|
||||
from solo.admin import SingletonModelAdmin
|
||||
|
||||
# Alliance Auth Custom CSS
|
||||
from allianceauth.custom_css.models import CustomCSS
|
||||
from allianceauth.custom_css.forms import CustomCSSAdminForm
|
||||
|
||||
# Alliance Auth Framework
|
||||
from allianceauth.framework.admin import SingletonModelAdmin
|
||||
|
||||
# Django
|
||||
from django.contrib import admin
|
||||
|
||||
|
||||
@admin.register(CustomCSS)
|
||||
class CustomCSSAdmin(SingletonModelAdmin):
|
||||
|
@ -2,13 +2,11 @@
|
||||
Models for the custom_css app
|
||||
"""
|
||||
|
||||
import hashlib
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
# Alliance Auth Framework
|
||||
from allianceauth.framework.models import SingletonModel
|
||||
# Django Solo
|
||||
from solo.models import SingletonModel
|
||||
|
||||
# Django
|
||||
from django.conf import settings
|
||||
@ -62,7 +60,7 @@ class CustomCSS(SingletonModel):
|
||||
|
||||
self.pk = 1
|
||||
|
||||
if len(self.css.replace(" ", "")) > 0:
|
||||
if self.css and len(self.css.replace(" ", "")) > 0:
|
||||
# Write the custom CSS to a file
|
||||
custom_css_file = open(
|
||||
f"{settings.STATIC_ROOT}allianceauth/custom-styles.css", "w+"
|
||||
|
@ -1,58 +0,0 @@
|
||||
"""
|
||||
Admin classes for the framework app
|
||||
"""
|
||||
|
||||
from django.contrib import admin
|
||||
|
||||
|
||||
class SingletonModelAdmin(admin.ModelAdmin):
|
||||
"""
|
||||
Singleton Model Admin
|
||||
Prevents Django admin users deleting the singleton or adding extra rows.
|
||||
"""
|
||||
|
||||
actions = None # Removes the default delete action.
|
||||
|
||||
def has_add_permission(self, request): # pylint: disable=unused-argument
|
||||
"""
|
||||
Has "add" permissions
|
||||
|
||||
:param request:
|
||||
:type request:
|
||||
:return:
|
||||
:rtype:
|
||||
"""
|
||||
|
||||
return self.model.objects.all().count() == 0
|
||||
|
||||
def has_change_permission(
|
||||
self, request, obj=None # pylint: disable=unused-argument
|
||||
):
|
||||
"""
|
||||
Has "change" permissions
|
||||
|
||||
:param request:
|
||||
:type request:
|
||||
:param obj:
|
||||
:type obj:
|
||||
:return:
|
||||
:rtype:
|
||||
"""
|
||||
|
||||
return True
|
||||
|
||||
def has_delete_permission(
|
||||
self, request, obj=None # pylint: disable=unused-argument
|
||||
):
|
||||
"""
|
||||
Has "delete" permissions
|
||||
|
||||
:param request:
|
||||
:type request:
|
||||
:param obj:
|
||||
:type obj:
|
||||
:return:
|
||||
:rtype:
|
||||
"""
|
||||
|
||||
return False
|
@ -1,47 +0,0 @@
|
||||
"""
|
||||
AA framework models
|
||||
"""
|
||||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class SingletonModel(models.Model):
|
||||
"""
|
||||
SingletonModel
|
||||
"""
|
||||
|
||||
class Meta: # pylint: disable=too-few-public-methods
|
||||
"""
|
||||
Model meta definitions
|
||||
"""
|
||||
|
||||
abstract = True
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
"""
|
||||
"Save" action
|
||||
|
||||
:param args:
|
||||
:type args:
|
||||
:param kwargs:
|
||||
:type kwargs:
|
||||
:return:
|
||||
:rtype:
|
||||
"""
|
||||
|
||||
self.pk = 1
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
"""
|
||||
"Delete" action
|
||||
|
||||
:param args:
|
||||
:type args:
|
||||
:param kwargs:
|
||||
:type kwargs:
|
||||
:return:
|
||||
:rtype:
|
||||
"""
|
||||
|
||||
pass # pylint: disable=unnecessary-pass
|
@ -22,6 +22,7 @@ INSTALLED_APPS = [
|
||||
'django.contrib.staticfiles',
|
||||
'django.contrib.humanize',
|
||||
'django_celery_beat',
|
||||
'solo',
|
||||
'bootstrapform',
|
||||
'django_bootstrap5', # https://github.com/zostera/django-bootstrap5
|
||||
'sortedm2m',
|
||||
|
@ -50,6 +50,7 @@ dependencies = [
|
||||
"django-esi>=5",
|
||||
"django-redis>=5.2",
|
||||
"django-registration<3.4,>=3.3",
|
||||
"django-solo",
|
||||
"django-sortedm2m",
|
||||
"dnspython",
|
||||
"mysqlclient>=2.1",
|
||||
|
Loading…
x
Reference in New Issue
Block a user