Compare commits
No commits in common. "master" and "1.3.9" have entirely different histories.
36 changed files with 36 additions and 671 deletions
|
|
@ -1 +1 @@
|
|||
1.5.0 (2ec4a5c)
|
||||
1.3.8 (7cf0496)
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
from django.db import models
|
||||
from django.urls import reverse
|
||||
|
||||
class Post(models.Model):
|
||||
name = models.CharField(max_length=200)
|
||||
|
|
@ -17,6 +16,3 @@ class Post(models.Model):
|
|||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('blog:post_detail', kwargs={'slug': self.slug})
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
from django.contrib import admin
|
||||
from .models import SiteSettings, Visit, Maintenance
|
||||
from .models import SiteSettings, Visit
|
||||
|
||||
@admin.register(SiteSettings)
|
||||
class SiteSettingsAdmin(admin.ModelAdmin):
|
||||
|
|
@ -28,10 +28,6 @@ class SiteSettingsAdmin(admin.ModelAdmin):
|
|||
}),
|
||||
)
|
||||
|
||||
@admin.register(Maintenance)
|
||||
class MaintenanceAdmin(admin.ModelAdmin):
|
||||
list_display = ("name","start_date", "end_date")
|
||||
|
||||
|
||||
@admin.register(Visit)
|
||||
class VisitAdmin(admin.ModelAdmin):
|
||||
|
|
|
|||
|
|
@ -1,14 +1,5 @@
|
|||
from django.utils.timesince import timesince
|
||||
|
||||
from .models import SiteSettings, Maintenance
|
||||
from .models import SiteSettings
|
||||
|
||||
def site_settings(request):
|
||||
# On récupère le premier objet, ou None s'il n'existe pas encore
|
||||
return {'settings': SiteSettings.objects.first()}
|
||||
|
||||
def site_maintenance(request):
|
||||
last = Maintenance.objects.last()
|
||||
start = last.start_date if last else None
|
||||
end = last.end_date if last else None
|
||||
delay = timesince(start, end) if start and end else None
|
||||
return {'maintenance': Maintenance.objects.last(), 'delay': delay}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
# Generated by Django 6.0 on 2025-12-17 10:25
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0005_sitesettings_receive_emails_active'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Maintenance',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('is_active', models.BooleanField(default=False)),
|
||||
('message', models.TextField(blank=True)),
|
||||
('start_date', models.DateTimeField(blank=True, null=True)),
|
||||
('end_date', models.DateTimeField(blank=True, null=True)),
|
||||
],
|
||||
),
|
||||
]
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
# Generated by Django 6.0 on 2025-12-17 10:26
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0006_maintenance'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='maintenance',
|
||||
name='name',
|
||||
field=models.CharField(blank=True, max_length=200),
|
||||
),
|
||||
]
|
||||
|
|
@ -35,12 +35,6 @@ class SiteSettings(models.Model):
|
|||
verbose_name = "Réglages du site"
|
||||
verbose_name_plural = "Réglages du site"
|
||||
|
||||
class Maintenance(models.Model):
|
||||
is_active = models.BooleanField(default=False)
|
||||
name = models.CharField(max_length=200, blank=True)
|
||||
message = models.TextField(blank=True)
|
||||
start_date = models.DateTimeField(blank=True, null=True)
|
||||
end_date = models.DateTimeField(blank=True, null=True)
|
||||
|
||||
class Visit(models.Model):
|
||||
"""Enregistrement simplifié des visites (agrégées par jour et visiteur).
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
from django.urls import path
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('update_database', views.update_database, name='update_database'),
|
||||
path('clear_cache', views.clear_cache, name='clear_cache'),
|
||||
path('regen_static_files', views.regen_static_files, name='regen_static_files'),
|
||||
path('reload_server', views.reload_server, name='reload_server')
|
||||
]
|
||||
|
|
@ -1,23 +1,3 @@
|
|||
from django.shortcuts import render
|
||||
from django.core.management import call_command
|
||||
from django.core.cache import cache
|
||||
import subprocess
|
||||
|
||||
def update_database(request):
|
||||
call_command('makemigrations')
|
||||
call_command('migrate')
|
||||
message = "La base de données à bien été mise à jour !"
|
||||
return render(request, 'home.html', {'message': message})
|
||||
|
||||
def clear_cache(request):
|
||||
cache.clear()
|
||||
message = "Le cache à bien été effacé !"
|
||||
return render(request, 'home.html', {'message': message})
|
||||
|
||||
def regen_static_files(request):
|
||||
call_command('collectstatic', '--noinput')
|
||||
message = "Les fichiers statics ont bien été générés !"
|
||||
return render(request, 'home.html', {'message': message})
|
||||
|
||||
def reload_server(request):
|
||||
pass
|
||||
# Create your views here.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class CoursesConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'courses'
|
||||
|
|
@ -55,8 +55,6 @@ INSTALLED_APPS = [
|
|||
'users',
|
||||
'progression',
|
||||
'blog',
|
||||
|
||||
'discord_integration.apps.DiscordIntegrationConfig',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
|
@ -86,7 +84,6 @@ TEMPLATES = [
|
|||
|
||||
'devart.context_processor.app_version',
|
||||
'core.context_processor.site_settings',
|
||||
'core.context_processor.site_maintenance',
|
||||
'courses.context_processors.course_list',
|
||||
'blog.context_processor.posts_list',
|
||||
],
|
||||
|
|
|
|||
|
|
@ -22,13 +22,12 @@ from django.http import HttpResponse
|
|||
from devart.sitemap import CourseSitemap, StaticViewSitemap
|
||||
from django.contrib.sitemaps.views import sitemap
|
||||
|
||||
# La vue pour le robots.txt
|
||||
def robots_txt(request):
|
||||
lines = [
|
||||
"User-agent: *",
|
||||
"Disallow: /admin/",
|
||||
"Disallow: /users/",
|
||||
"Disallow: /maintenance/",
|
||||
"Disallow: /core/",
|
||||
"Allow: /",
|
||||
"Sitemap: https://partirdezero.com/sitemap.xml", # On indique déjà où sera le plan
|
||||
]
|
||||
|
|
@ -40,7 +39,6 @@ sitemaps_dict = {
|
|||
}
|
||||
|
||||
urlpatterns = [
|
||||
path('core/', include('core.urls')),
|
||||
path('admin/', admin.site.urls),
|
||||
path('', include('home.urls')),
|
||||
path('courses/', include('courses.urls')),
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class DiscordIntegrationConfig(AppConfig):
|
||||
name = 'discord_integration'
|
||||
|
||||
def ready(self):
|
||||
import discord_integration.signals
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
import discord
|
||||
from discord import app_commands
|
||||
|
||||
intents = discord.Intents.default()
|
||||
intents.members = True
|
||||
intents.message_content = True
|
||||
|
||||
class Bot(discord.Client):
|
||||
def __init__(self, *, intents: discord.Intents):
|
||||
super().__init__(intents=intents)
|
||||
self.tree = app_commands.CommandTree(self)
|
||||
|
||||
async def setup_hook(self):
|
||||
await self.tree.sync()
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
from asgiref.sync import sync_to_async
|
||||
import discord
|
||||
from discord.ext import tasks
|
||||
from discord_integration.models import DiscordNotification
|
||||
|
||||
def get_pending_notifications():
|
||||
return list(DiscordNotification.objects.filter(is_announced=False))
|
||||
|
||||
def mark_as_done(notif):
|
||||
notif.is_announced = True
|
||||
notif.save()
|
||||
|
||||
def process_notifications():
|
||||
# Cette fonction fait tout le travail SQL "interdit" en mode async
|
||||
notifs = list(DiscordNotification.objects.filter(is_announced=False))
|
||||
results = []
|
||||
for n in notifs:
|
||||
# Ici, on peut toucher à content_object car on est en mode "sync" !
|
||||
obj = n.content_object
|
||||
if obj:
|
||||
# 1. On cherche la description, sinon le contenu, sinon rien
|
||||
teaser = getattr(obj, 'description', getattr(obj, 'content', ""))
|
||||
|
||||
# 2. Sécurité : On coupe à 3000 caractères pour éviter les erreurs Discord
|
||||
if len(teaser) > 3000:
|
||||
teaser = teaser[:2997] + "..."
|
||||
|
||||
results.append({
|
||||
'notif_model': n,
|
||||
'title': getattr(obj, 'title', getattr(obj, 'name', str(obj))),
|
||||
'url': obj.get_absolute_url() if hasattr(obj, 'get_absolute_url') else "#",
|
||||
'summary': teaser
|
||||
})
|
||||
|
||||
return results
|
||||
|
||||
@tasks.loop(seconds=5.0)
|
||||
async def check_announcements(client, channel_id):
|
||||
announcements = await sync_to_async(process_notifications)()
|
||||
|
||||
for data in announcements:
|
||||
title = data['title']
|
||||
link = data['url']
|
||||
notif = data['notif_model']
|
||||
summary = data['summary']
|
||||
|
||||
embed = discord.Embed(
|
||||
title = f"📣 Nouveau contenu : {title}",
|
||||
url = f"https://partirdezero.com{link}",
|
||||
description = summary,
|
||||
color=discord.Color.blue()
|
||||
)
|
||||
|
||||
channel_id = client.get_channel(channel_id)
|
||||
if channel_id:
|
||||
await channel_id.send(embed=embed)
|
||||
await sync_to_async(mark_as_done)(notif)
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
XP = {
|
||||
"MESSAGE": 5
|
||||
}
|
||||
|
||||
RANK = {
|
||||
1: "Nouveau membre",
|
||||
3: "Membre",
|
||||
7: "Habitué du comptoir",
|
||||
12: "Expert",
|
||||
18: "Chevalier du code",
|
||||
25: "Baron C#",
|
||||
35: "Lord Script",
|
||||
50: "Héros des architectures",
|
||||
75: "Vétéran",
|
||||
100: "Légende"
|
||||
}
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
from datetime import datetime, timezone
|
||||
|
||||
from asgiref.sync import sync_to_async
|
||||
import discord
|
||||
from datetime import datetime
|
||||
from discord_integration.models import DiscordLevel
|
||||
from enums import XP, RANK
|
||||
from discord import app_commands
|
||||
|
||||
def get_user(id_discord):
|
||||
user, created = DiscordLevel.objects.get_or_create(discord_id=id_discord)
|
||||
return user, created
|
||||
|
||||
def update_user_xp(user, xp_to_add):
|
||||
leveled_up = False
|
||||
|
||||
# 1. Mise à jour de l'XP et du temps
|
||||
user.total_xp += xp_to_add
|
||||
user.last_message = datetime.now(timezone.utc)
|
||||
|
||||
# 2. Calcul du niveau théorique
|
||||
calculated_level = int(0.5 + (0.25 + user.total_xp / 50)**0.5)
|
||||
|
||||
# 3. Vérification du Level Up
|
||||
if calculated_level > user.level:
|
||||
user.level = calculated_level
|
||||
leveled_up = True
|
||||
|
||||
new_rank = RANK[1]
|
||||
|
||||
for level_threshold, rank_name in RANK.items():
|
||||
if user.level >= level_threshold:
|
||||
new_rank = rank_name
|
||||
else:
|
||||
break
|
||||
|
||||
user.rank = new_rank
|
||||
|
||||
user.save()
|
||||
return user, leveled_up
|
||||
|
||||
async def check_add_xp(message, client):
|
||||
id_discord = message.author.id
|
||||
username = message.author.name
|
||||
|
||||
user_db, created = await sync_to_async(get_user)(id_discord)
|
||||
|
||||
if not created and user_db.last_message:
|
||||
delta = datetime.now(timezone.utc) - user_db.last_message
|
||||
if delta.seconds < 6:
|
||||
return
|
||||
|
||||
user_db, leveled_up = await sync_to_async(update_user_xp)(user_db, XP["MESSAGE"])
|
||||
|
||||
if leveled_up:
|
||||
# On crée un petit message sympa
|
||||
await message.channel.send(
|
||||
f"🎊 **LEVEL UP** 🎊\nBravo {message.author.mention}, tu passes **niveau {user_db.level}** ! "
|
||||
f"On applaudit tous bien fort ! Clap Clap !!"
|
||||
)
|
||||
else:
|
||||
# Juste un petit log console pour toi
|
||||
print(f"✨ XP ajouté pour {message.author.name} (Total: {user_db.total_xp})")
|
||||
|
||||
# AJOUT DES COMMANDES /xp et /level
|
||||
@app_commands.command(name="level", description="Permet de connaitre ton xp actuel")
|
||||
async def get_xp(interaction: discord.Interaction):
|
||||
user_id = interaction.user.id
|
||||
user_db, _ = await sync_to_async(get_user)(user_id)
|
||||
await interaction.response.send_message(f"{interaction.user.mention} : Tu as {user_db.total_xp} XP et tu es niveau {user_db.level} !\nTon rang est **{user_db.rank}** !")
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
import discord
|
||||
import django
|
||||
import os, sys
|
||||
|
||||
import dotenv
|
||||
from discord.ext import commands
|
||||
|
||||
# On import django pour communiquer avec
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
if BASE_DIR not in sys.path:
|
||||
sys.path.insert(0, BASE_DIR)
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'devart.settings')
|
||||
django.setup()
|
||||
|
||||
# Import des fonctions
|
||||
from role_logic import check_role_reaction
|
||||
from announces_logic import check_announcements
|
||||
from random_phrase import get_random_phrase
|
||||
from level_logic import check_add_xp, get_xp
|
||||
import BotClass
|
||||
|
||||
# CONFIGURATION
|
||||
TOKEN = dotenv.get_key(BASE_DIR + '/.env', 'D_TOKEN')
|
||||
MESSAGE_ID = 1450928822156263505 # L'ID du message des règles (clic droit > Copier l'identifiant)
|
||||
ROLE_ID = 1450920002868875435 # L'ID du rôle "Membres"
|
||||
ANNOUNCEMENT_CHANNEL_ID = 1450912559774306346
|
||||
EMOJI_VALIDATION = "✅"
|
||||
|
||||
# LES INTENTS (PERMISSIONS DU BOT)
|
||||
intents = discord.Intents.default()
|
||||
intents.members = True # Important pour pouvoir donner des rôles
|
||||
intents.message_content = True
|
||||
|
||||
client = BotClass.Bot(intents=intents)
|
||||
client.tree.add_command(get_random_phrase)
|
||||
client.tree.add_command(get_xp)
|
||||
|
||||
@client.event
|
||||
async def on_ready():
|
||||
print(f'✅ Bot connecté : {client.user}')
|
||||
|
||||
try:
|
||||
synced = await client.tree.sync()
|
||||
print(f"🌍 {len(synced)} commandes slash synchronisées !")
|
||||
except Exception as e:
|
||||
print(f"❌ Erreur de synchronisation : {e}")
|
||||
|
||||
if not check_announcements.is_running():
|
||||
check_announcements.start(client, ANNOUNCEMENT_CHANNEL_ID)
|
||||
|
||||
@client.event
|
||||
async def on_message(message):
|
||||
if message.author == client.user:
|
||||
return
|
||||
if message.guild is None:
|
||||
author = message.author
|
||||
await message.channel.send("Bonjour !\nJe suis un bot destiné à tester les nouvelles fonctionnalités de Discord. Pour le moment, je suis qu'en lecture seule.")
|
||||
else:
|
||||
await check_add_xp(message, client)
|
||||
|
||||
|
||||
@client.event
|
||||
async def on_raw_reaction_add(payload):
|
||||
# On envoie tout le nécessaire à notre fonction dans role_logic.py
|
||||
await check_role_reaction(
|
||||
payload,
|
||||
client,
|
||||
MESSAGE_ID,
|
||||
ROLE_ID,
|
||||
EMOJI_VALIDATION
|
||||
)
|
||||
|
||||
client.run(TOKEN)
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
import discord
|
||||
import random
|
||||
|
||||
from discord import app_commands
|
||||
|
||||
phrase = [
|
||||
"Yo !",
|
||||
"Quoi de neuf ?",
|
||||
"Je suis occupé à compter mes octets.",
|
||||
"Vive la Belgique ! 🇧🇪",
|
||||
"C’est pas un bug, c’est une fonctionnalité non documentée ! 🐛",
|
||||
"Est-ce qu’on peut dire que mon code est une œuvre d’art ? Non ? Dommage.",
|
||||
"Je ne plante pas, je fais une pause créative.",
|
||||
"Quelqu’un a vu mon point-virgule ? Il a disparu depuis le dernier commit.",
|
||||
"Je mangerais bien une mitraillette sauce andalouse, mais mon système digestif est en 404. 🍟",
|
||||
"42. Voilà. Maintenant, pose-moi une vraie question.",
|
||||
"On mange quoi ? Ah non, c'est vrai, je suis un robot... Tristesse infinie. 🤖",
|
||||
"C'est écrit en Python, donc c'est forcément élégant, non ?",
|
||||
"Un petit café ? Pour moi, une petite dose d'électricité suffira.",
|
||||
"Je parie que tu n'as pas encore fait ton `git push` aujourd'hui. Je te surveille ! 👀",
|
||||
"En Belgique, on n'a peut-être pas toujours du soleil, mais on a les meilleures frites ! 🇧🇪🍟",
|
||||
"Il y a 10 types de personnes : celles qui comprennent le binaire, et les autres.",
|
||||
"Mon processeur chauffe... soit je réfléchis trop, soit ton code est trop complexe !",
|
||||
"Tout va bien, tant que personne ne touche au dossier `migrations` de Django...",
|
||||
"Sais-tu pourquoi les développeurs détestent la nature ? Parce qu'il y a trop de bugs. 🌳",
|
||||
"On n'est pas là pour trier des lentilles, une fois ! On code ou quoi ? 🇧🇪"
|
||||
]
|
||||
|
||||
@app_commands.command(name="random_phrase", description="Envoi une phrase aléatoire !")
|
||||
async def get_random_phrase(interaction: discord.Interaction):
|
||||
choice = random.choice(phrase)
|
||||
await interaction.response.send_message(choice)
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
import discord
|
||||
|
||||
|
||||
async def check_role_reaction(payload, client, target_message_id, target_role_id, target_emoji):
|
||||
# 1. On vérifie si c'est le bon message
|
||||
if payload.message_id != target_message_id:
|
||||
return # On ignore si ce n'est pas le bon message
|
||||
|
||||
# 2. On vérifie si c'est le bon emoji
|
||||
if str(payload.emoji) == target_emoji:
|
||||
guild = client.get_guild(payload.guild_id)
|
||||
if guild is None:
|
||||
print("Erreur: Impossible de trouver le serveur (Guild is None).")
|
||||
return
|
||||
|
||||
member = guild.get_member(payload.user_id)
|
||||
if member is None:
|
||||
print("Erreur: Impossible de trouver le membre (Member is None).")
|
||||
return
|
||||
|
||||
role = guild.get_role(target_role_id)
|
||||
if role is None:
|
||||
print("Erreur : Le role n'existe pas.")
|
||||
return
|
||||
|
||||
try:
|
||||
await member.add_roles(role)
|
||||
print(f"🎉 SUCCÈS : Rôle donné à {member.name} !")
|
||||
try:
|
||||
await member.send("Bienvenue ! Tu as accès aux salons.")
|
||||
except:
|
||||
print("Note: MP bloqués par l'utilisateur.")
|
||||
except discord.Forbidden:
|
||||
print("⛔ ERREUR PERMISSION : Je n'ai pas le droit de donner ce rôle !")
|
||||
print(
|
||||
"👉 SOLUTION : Va dans Paramètres Serveur > Rôles. Glisse le rôle 'PartirDeZero Bot' AU-DESSUS du rôle 'Membres'.")
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Erreur inconnue : {e}")
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
# Generated by Django 6.0 on 2025-12-18 08:23
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('contenttypes', '0002_remove_content_type_name'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='DiscordNotification',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('object_id', models.PositiveIntegerField()),
|
||||
('is_announced', models.BooleanField(default=False)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.contenttype')),
|
||||
],
|
||||
),
|
||||
]
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
# Generated by Django 6.0 on 2025-12-18 11:57
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('discord_integration', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='DiscordLevel',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('discord_id', models.BigIntegerField()),
|
||||
('total_xp', models.PositiveIntegerField(default=0)),
|
||||
('level', models.PositiveIntegerField(default=1)),
|
||||
('rank', models.TextField(default='Nouveau membre')),
|
||||
('last_message', models.DateTimeField(auto_now_add=True)),
|
||||
],
|
||||
),
|
||||
]
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
from django.contrib.contenttypes.fields import GenericForeignKey
|
||||
from django.db import models
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
|
||||
class DiscordNotification(models.Model):
|
||||
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
|
||||
object_id = models.PositiveIntegerField()
|
||||
content_object = GenericForeignKey('content_type', 'object_id')
|
||||
is_announced = models.BooleanField(default=False)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
def __str__(self):
|
||||
return f"Annonces pour {self.content_object} ({'✅' if self.is_announced else '⏳'})"
|
||||
|
||||
class DiscordLevel(models.Model):
|
||||
discord_id = models.BigIntegerField()
|
||||
total_xp = models.PositiveIntegerField(default=0)
|
||||
level = models.PositiveIntegerField(default=1)
|
||||
rank = models.TextField(default="Nouveau membre")
|
||||
last_message = models.DateTimeField(auto_now_add=True)
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
from .models import DiscordNotification
|
||||
|
||||
@receiver(post_save, sender="blog.Post")
|
||||
def create_discord_notification_blog(sender, instance, created, **kwargs):
|
||||
if created:
|
||||
DiscordNotification.objects.create(content_object=instance)
|
||||
|
||||
@receiver(post_save, sender="courses.Course")
|
||||
def create_discord_notification_course(sender, instance, created, **kwargs):
|
||||
if created:
|
||||
DiscordNotification.objects.create(content_object=instance)
|
||||
|
||||
@receiver(post_save, sender="courses.Lesson")
|
||||
def create_discord_notification_lesson(sender, instance, created, **kwargs):
|
||||
if created:
|
||||
DiscordNotification.objects.create(content_object=instance)
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
|
|
@ -2673,21 +2673,3 @@ ul.flash_messages li.success {
|
|||
background-color: var(--success);
|
||||
color: var(--success-contrast);
|
||||
}
|
||||
|
||||
.message-warning {
|
||||
color: var(--neutral-900);
|
||||
background: var(--neutral-200);
|
||||
border: 1px solid var(--warning);
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.message-info {
|
||||
color: var(--neutral-900);
|
||||
background: var(--neutral-200);
|
||||
border: 1px solid var(--primary);
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
|
@ -13,85 +13,3 @@ function show(id) {
|
|||
let buttonChange = document.getElementById(id);
|
||||
buttonChange.onclick = function() { hide(id); };
|
||||
}
|
||||
|
||||
// Fonction pour supprimer le message d'alerte après 5 secondes
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
let messages = document.querySelector('.flash_messages')
|
||||
if (messages) {
|
||||
setTimeout(function() {
|
||||
messages.style.opacity = 0;
|
||||
setTimeout(function() {
|
||||
messages.style.display = 'none';
|
||||
}, 1000);
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
// Theme toggle setup
|
||||
var toggle = document.getElementById('themeToggle');
|
||||
var themeLink = document.getElementById('theme-css');
|
||||
function applyTheme(theme) {
|
||||
document.documentElement.setAttribute('data-theme', theme);
|
||||
if (theme === 'light') {
|
||||
if (themeLink) themeLink.href = themeLink.href.replace('colors_dark.css', 'colors_light.css');
|
||||
} else {
|
||||
if (themeLink) themeLink.href = themeLink.href.replace('colors_light.css', 'colors_dark.css');
|
||||
}
|
||||
var icon = toggle && toggle.querySelector('i');
|
||||
if (icon) {
|
||||
icon.classList.remove('fa-sun','fa-moon');
|
||||
icon.classList.add(theme === 'light' ? 'fa-moon' : 'fa-sun');
|
||||
}
|
||||
if (toggle) {
|
||||
toggle.setAttribute('aria-pressed', theme === 'dark' ? 'true' : 'false');
|
||||
toggle.setAttribute('aria-label', theme === 'light' ? 'Activer le thème sombre' : 'Activer le thème clair');
|
||||
toggle.title = toggle.getAttribute('aria-label');
|
||||
}
|
||||
}
|
||||
try {
|
||||
var current = document.documentElement.getAttribute('data-theme') || 'dark';
|
||||
applyTheme(current);
|
||||
if (toggle) {
|
||||
toggle.addEventListener('click', function() {
|
||||
var next = (document.documentElement.getAttribute('data-theme') === 'light') ? 'dark' : 'light';
|
||||
localStorage.setItem('pdz-theme', next);
|
||||
applyTheme(next);
|
||||
});
|
||||
}
|
||||
} catch(e) {}
|
||||
|
||||
// Mobile nav toggle
|
||||
try {
|
||||
var navToggle = document.getElementById('navToggle');
|
||||
var primaryNav = document.getElementById('primaryNav');
|
||||
if (navToggle && primaryNav) {
|
||||
function setExpanded(expanded) {
|
||||
navToggle.setAttribute('aria-expanded', expanded ? 'true' : 'false');
|
||||
navToggle.setAttribute('aria-label', expanded ? 'Fermer le menu' : 'Ouvrir le menu');
|
||||
var icon = navToggle.querySelector('i');
|
||||
if (icon) {
|
||||
icon.classList.remove('fa-bars','fa-xmark');
|
||||
icon.classList.add(expanded ? 'fa-xmark' : 'fa-bars');
|
||||
}
|
||||
primaryNav.classList.toggle('is-open', expanded);
|
||||
}
|
||||
|
||||
navToggle.addEventListener('click', function() {
|
||||
var expanded = navToggle.getAttribute('aria-expanded') === 'true';
|
||||
setExpanded(!expanded);
|
||||
});
|
||||
|
||||
// Close menu when a link is clicked (on small screens)
|
||||
primaryNav.addEventListener('click', function(e) {
|
||||
var target = e.target;
|
||||
if (target.tagName === 'A' || target.closest('a')) {
|
||||
setExpanded(false);
|
||||
}
|
||||
});
|
||||
|
||||
// Close on Escape
|
||||
document.addEventListener('keydown', function(e) {
|
||||
if (e.key === 'Escape') setExpanded(false);
|
||||
});
|
||||
}
|
||||
} catch(e) {}
|
||||
});
|
||||
|
|
@ -84,9 +84,6 @@
|
|||
<script defer>hljs.highlightAll();</script>
|
||||
</head>
|
||||
<body>
|
||||
{% if maintenance.is_active == True %}
|
||||
{% include "maintenance.html" %}
|
||||
{% else %}
|
||||
{% now "n" as month %}
|
||||
{% if month == '12' %}
|
||||
<!-- Overlay neige discret, non interactif -->
|
||||
|
|
@ -111,6 +108,5 @@
|
|||
{% block footer %}
|
||||
{% include "partials/_footer.html" %}
|
||||
{% endblock %}
|
||||
{% endif %}
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
{% load comment_format %}
|
||||
<section>
|
||||
<h1>Maintenance : {{ maintenance.name }}</h1>
|
||||
{{ maintenance.message|comment_markdown }}
|
||||
<div class="text-right">Durée estimée : {{ delay }}</div>
|
||||
<div class="text-right">Début de la maintenance : {{ maintenance.start_date }}</div>
|
||||
<div class="text-right">Fin de la maintenance estimé : {{ maintenance.end_date }}</div>
|
||||
|
||||
{% if message %}
|
||||
<h2>{{ message }}</h2>
|
||||
{% endif %}
|
||||
|
||||
{% if user.is_superuser %}
|
||||
<div style="border-bottom: 2px solid white"></div>
|
||||
<div>
|
||||
<ul>
|
||||
<li><a href="{% url 'update_database' %}">Mettre à jour la base de données</a></li>
|
||||
<li><a href="">Nettoyer la base de données</a></li>
|
||||
<li><a href="{% url 'clear_cache' %}">Effacer le cache</a></li>
|
||||
<li><a href="{% url 'regen_static_files' %}">Régénérer les fichiers static</a></li>
|
||||
<div style="border-bottom: 2px solid white; margin: 5px;"></div>
|
||||
<li><a href="{% url 'admin:index' %}" class="btn btn-warning" target="_blank">Panel Admin</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="message-warning"><i class="fa-solid fa-terminal" style="color:orange;border-right: 1px solid orange; padding: 5px;"> </i><strong> Commande de redemarrage serveur : </strong>kill -HUP $(cat /var/www/vhosts/partirdezero.com/httpdocs/run/gunicorn.pid)</div>
|
||||
<div class="message-info"><i class="fa-solid fa-link" style="color:orange;border-right: 1px solid orange; padding: 5px;"> </i> <a href="https://trusting-moser.82-165-125-100.plesk.page:8443/modules/ssh-terminal/" target="_blank">Accès terminal SSH</a></div>
|
||||
{% endif %}
|
||||
</section>
|
||||
|
|
@ -29,7 +29,6 @@
|
|||
{% if settings.contact_email %}
|
||||
<li><a href="mailto:contact@exemple.com"><i class="fa-solid fa-envelope"></i> Email</a></li>
|
||||
{% endif %}
|
||||
<li><a href="https://discord.gg/bAkuKHWFqU" target="_blank"><i class="fab fa-discord"></i> Communauté</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -45,10 +45,11 @@
|
|||
{% endif %}
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="https://discord.gg/7kk6AJsAVn" target="_blank" class="button"><i class="fab fa-discord"></i> Discord</a></li>
|
||||
{% if user.is_authenticated and user.is_staff %}
|
||||
<li><a href="{% url 'admin:index' %}" class="button button-danger" title="Administration">Admin</a></li>
|
||||
<li><a href="{% url 'home:stats_dashboard' %}" class="button button-warning" title="Stats">Stats</a></li>
|
||||
<li>
|
||||
<a href="{% url 'admin:index' %}" class="button button-danger" title="Administration">Admin</a>
|
||||
<a href="{% url 'home:stats_dashboard' %}" class="button button-warning" title="Stats">Stats</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li>
|
||||
{% if user.is_authenticated %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue