mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-23 19:22:27 +02:00
Compare commits
No commits in common. "0d5f22288b226ea17291f1629a57b9d2554f9686" and "ecc9e68330b420dfa4fc04f962f9e768baba6886" have entirely different histories.
0d5f22288b
...
ecc9e68330
@ -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,11 +2,13 @@
|
||||
Models for the custom_css app
|
||||
"""
|
||||
|
||||
import hashlib
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
# Django Solo
|
||||
from solo.models import SingletonModel
|
||||
# Alliance Auth Framework
|
||||
from allianceauth.framework.models import SingletonModel
|
||||
|
||||
# Django
|
||||
from django.conf import settings
|
||||
@ -60,7 +62,7 @@ class CustomCSS(SingletonModel):
|
||||
|
||||
self.pk = 1
|
||||
|
||||
if self.css and len(self.css.replace(" ", "")) > 0:
|
||||
if 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+"
|
||||
|
58
allianceauth/framework/admin.py
Normal file
58
allianceauth/framework/admin.py
Normal file
@ -0,0 +1,58 @@
|
||||
"""
|
||||
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
|
47
allianceauth/framework/models.py
Normal file
47
allianceauth/framework/models.py
Normal file
@ -0,0 +1,47 @@
|
||||
"""
|
||||
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,7 +22,6 @@ INSTALLED_APPS = [
|
||||
'django.contrib.staticfiles',
|
||||
'django.contrib.humanize',
|
||||
'django_celery_beat',
|
||||
'solo',
|
||||
'bootstrapform',
|
||||
'django_bootstrap5', # https://github.com/zostera/django-bootstrap5
|
||||
'sortedm2m',
|
||||
|
@ -50,7 +50,6 @@ 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