Add initial migrations, admin configurations, and base CSS for the project
This commit is contained in:
parent
16897b6010
commit
8fe6fe5390
19 changed files with 2101 additions and 68 deletions
0
core/__init__.py
Normal file
0
core/__init__.py
Normal file
26
core/admin.py
Normal file
26
core/admin.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
from django.contrib import admin
|
||||
from .models import SiteSettings
|
||||
|
||||
@admin.register(SiteSettings)
|
||||
class SiteSettingsAdmin(admin.ModelAdmin):
|
||||
# On empêche d'ajouter une nouvelle config s'il en existe déjà une
|
||||
def has_add_permission(self, request):
|
||||
return not SiteSettings.objects.exists()
|
||||
|
||||
# On empêche de supprimer la config (trop dangereux)
|
||||
def has_delete_permission(self, request, obj=None):
|
||||
return False
|
||||
|
||||
# Petite astuce visuelle pour l'admin
|
||||
fieldsets = (
|
||||
('Général', {
|
||||
'fields': ('site_name', 'site_logo')
|
||||
}),
|
||||
('Réseaux Sociaux', {
|
||||
'fields': ('facebook_url', 'twitter_url', 'youtube_url'),
|
||||
'classes': ('collapse',) # Cache cette section par défaut pour alléger
|
||||
}),
|
||||
('Contact', {
|
||||
'fields': ('contact_email',)
|
||||
}),
|
||||
)
|
||||
5
core/apps.py
Normal file
5
core/apps.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class CoreConfig(AppConfig):
|
||||
name = 'core'
|
||||
33
core/migrations/0001_initial.py
Normal file
33
core/migrations/0001_initial.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# Generated by Django 6.0 on 2025-12-10 18:32
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='SiteSettings',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('site_name', models.CharField(default='Mon Super Site', max_length=200)),
|
||||
('site_logo', models.ImageField(blank=True, upload_to='settings/')),
|
||||
('contact_email', models.EmailField(blank=True, max_length=254)),
|
||||
('facebook_url', models.URLField(blank=True)),
|
||||
('twitter_url', models.URLField(blank=True)),
|
||||
('youtube_url', models.URLField(blank=True)),
|
||||
('instagram_url', models.URLField(blank=True)),
|
||||
('linkedin_url', models.URLField(blank=True)),
|
||||
('github_url', models.URLField(blank=True)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Réglages du site',
|
||||
'verbose_name_plural': 'Réglages du site',
|
||||
},
|
||||
),
|
||||
]
|
||||
0
core/migrations/__init__.py
Normal file
0
core/migrations/__init__.py
Normal file
29
core/models.py
Normal file
29
core/models.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
from django.db import models
|
||||
|
||||
class SiteSettings(models.Model):
|
||||
site_name = models.CharField(max_length=200, default="Mon Super Site")
|
||||
site_logo = models.ImageField(upload_to='settings/', blank=True)
|
||||
contact_email = models.EmailField(blank=True)
|
||||
|
||||
# Réseaux sociaux
|
||||
facebook_url = models.URLField(blank=True)
|
||||
twitter_url = models.URLField(blank=True)
|
||||
youtube_url = models.URLField(blank=True)
|
||||
instagram_url = models.URLField(blank=True)
|
||||
linkedin_url = models.URLField(blank=True)
|
||||
github_url = models.URLField(blank=True)
|
||||
|
||||
# L'astuce pour qu'il n'y ait qu'un seul réglage
|
||||
def save(self, *args, **kwargs):
|
||||
self.pk = 1 # On force l'ID à 1. Si tu sauvegardes, ça écrase l'existant.
|
||||
super(SiteSettings, self).save(*args, **kwargs)
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
pass # On empêche la suppression. On ne peut pas supprimer les réglages.
|
||||
|
||||
def __str__(self):
|
||||
return "Configuration Générale"
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Réglages du site"
|
||||
verbose_name_plural = "Réglages du site"
|
||||
3
core/tests.py
Normal file
3
core/tests.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
3
core/views.py
Normal file
3
core/views.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
Loading…
Add table
Add a link
Reference in a new issue