Преглед на файлове

Merge branch 'master' of ssh://192.168.1.24:10022/MrDuhaz/core

Mr Duhaz преди 2 месеца
родител
ревизия
e276a7db60
променени са 11 файла, в които са добавени 289 реда и са изтрити 87 реда
  1. 15 0
      .gitignore
  2. 132 2
      apps.py
  3. 18 0
      migrations/0022_page_p_proteger.py
  4. 23 0
      migrations/0023_auto_20240730_2056.py
  5. 23 0
      migrations/0024_auto_20240730_2235.py
  6. 23 0
      migrations/0025_auto_20240730_2241.py
  7. 14 1
      models.py
  8. 3 3
      templates/base.html
  9. 3 3
      templates/base_no_card.html
  10. 22 23
      templates/login.html
  11. 13 55
      views.py

+ 15 - 0
.gitignore

@@ -84,3 +84,18 @@ migrations/__pycache__/0018_speed_dial_sd_groupe.cpython-312.pyc
 migrations/__pycache__/0019_alter_speed_dial_sd_groupe.cpython-312.pyc
 migrations/__pycache__/0020_alter_speed_dial_sd_titre.cpython-312.pyc
 migrations/__pycache__/0021_auto_20240423_1338.cpython-312.pyc
+migrations/__pycache__/0016_groupe.cpython-39.pyc
+migrations/__pycache__/0017_groupe_g_description.cpython-39.pyc
+migrations/__pycache__/0018_speed_dial_sd_groupe.cpython-39.pyc
+migrations/__pycache__/0019_alter_speed_dial_sd_groupe.cpython-39.pyc
+migrations/__pycache__/0020_alter_speed_dial_sd_titre.cpython-39.pyc
+migrations/__pycache__/0021_auto_20240423_1338.cpython-39.pyc
+migrations/__pycache__/0022_page_p_proteger.cpython-39.pyc
+migrations/__pycache__/0022_page_p_proteger.cpython-312.pyc
+migrations/__pycache__/0023_auto_20240723_1757.cpython-312.pyc
+migrations/__pycache__/0023_auto_20240730_2056.cpython-312.pyc
+migrations/__pycache__/0023_auto_20240730_2056.cpython-39.pyc
+migrations/__pycache__/0024_auto_20240730_2235.cpython-39.pyc
+migrations/__pycache__/0024_auto_20240730_2235.cpython-312.pyc
+migrations/__pycache__/0025_auto_20240730_2241.cpython-39.pyc
+migrations/__pycache__/0025_auto_20240730_2241.cpython-312.pyc

+ 132 - 2
apps.py

@@ -1,5 +1,135 @@
+import sys
 from django.apps import AppConfig
 
-
 class CoreConfig(AppConfig):
-    name = 'core'
+	name = 'core'
+
+	def ready(self):
+
+		if 'migrate' in sys.argv:
+			return
+
+		print("-- Démarage du Core --")
+		print(">> Vérification des variables d'environement")
+
+		from core.models import Data
+		
+		print(">>> check site-name")
+		try :
+			data = Data.objects.get(d_titre_slugify = "site-name")
+		except:
+			data = Data()
+			data.d_titre = "site-name"
+			data.d_type = "txt"
+			data.d_variable = "Duhaz Core"
+			data.save()
+		print(">>> check site-logo")
+		try :
+			data = Data.objects.get(d_titre_slugify = "site-logo")
+		except:
+			data = Data()
+			data.d_titre = "site-logo"
+			data.d_type = "txt"
+			data.d_variable = "far fa-clone"
+			data.save()
+
+		print(">>> heck site-version")
+		try :
+			data = Data.objects.get(d_titre_slugify = "site-version")
+		except :
+			data = Data()
+			data.d_titre = "site-version"
+			data.d_type = "txt"
+			data.d_variable = "Jan. 2024"
+			data.save()
+
+		print(">>> check background-color")
+		try :
+			data = Data.objects.get(d_titre_slugify = "background-color")
+		except :
+			data = Data()
+			data.d_titre = "background-color"
+			data.d_type = "txt"
+			data.d_variable = "#999"
+			data.save()
+
+		print(">>> check background")
+		try :
+			data = Data.objects.get(d_titre_slugify = "background")
+		except :
+			data = Data()
+			data.d_titre = "background"
+			data.d_type = "txt"
+			data.d_variable = "background.jpeg"
+			data.save()
+		
+		print(">>> check background-logo")
+		try :
+			data = Data.objects.get(d_titre_slugify = "background-logo")
+		except :
+			data = Data()
+			data.d_titre = "background-logo"
+			data.d_type = "txt"
+			data.d_variable = "logo-txt-Mrduhaz.png"
+			data.save()
+
+		print(">>> check login-menu")
+		try :
+			data = Data.objects.get(d_titre_slugify = "login-menu")
+		except :
+			data = Data()
+			data.d_titre = "login-menu"
+			data.d_type = "txt"
+			data.d_variable = "True"
+			data.save()
+
+		print(">>> check includ-right-panel")
+		try :
+			data = Data.objects.get(d_titre_slugify = "includ-right-panel")
+		except :
+			data = Data()
+			data.d_titre = "includ-right-panel"
+			data.d_type = "txt"
+			data.d_variable = "None"
+			data.save()
+
+		print(">>> check card-main-panel")
+		try :
+			data = Data.objects.get(d_titre_slugify = "card-main-panel")
+		except :
+			data = Data()
+			data.d_titre = "card-main-panel"
+			data.d_type = "txt"
+			data.d_variable = "True"
+			data.save()
+
+		print(">>> check card-right-panel")
+		try :
+			data = Data.objects.get(d_titre_slugify = "card-right-panel")
+		except :
+			data = Data()
+			data.d_titre = "card-right-panel"
+			data.d_type = "txt"
+			data.d_variable = "True"
+			data.save()
+
+		print(">> Vérification des pages par default")
+
+		from core.models import Page
+		print(">>> check bienvenus ")
+		try :
+			page = Page.objects.get(p_titre_slugify = "bienvenus")
+		except :
+			page = Page()
+			page.p_titre = "Bienvenus"
+			page.p_icone = "fas fa-home"
+			page.p_contenu = "Bravo,</br>Ceci est votre 1er page."
+			page.p_description = "Bravo, ceci est votre 1er page."
+			page.p_adresse = "/"
+			page.p_publier = True
+			page.p_type = "sys"
+
+			page.save()
+
+		
+

+ 18 - 0
migrations/0022_page_p_proteger.py

@@ -0,0 +1,18 @@
+# Generated by Django 3.2.23 on 2024-07-21 18:46
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('core', '0021_auto_20240423_1338'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='page',
+            name='p_proteger',
+            field=models.BooleanField(default=False, verbose_name='Disponible que si authentifier'),
+        ),
+    ]

+ 23 - 0
migrations/0023_auto_20240730_2056.py

@@ -0,0 +1,23 @@
+# Generated by Django 3.2.23 on 2024-07-30 18:56
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('core', '0022_page_p_proteger'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='page',
+            name='p_card_main_panel',
+            field=models.CharField(choices=[('def', 'Default'), ('oui', 'Oui'), ('non', 'Non')], default='def', max_length=3, verbose_name='Afficage du cadre central'),
+        ),
+        migrations.AddField(
+            model_name='page',
+            name='p_card_right_panel',
+            field=models.CharField(choices=[('def', 'Default'), ('oui', 'Oui'), ('non', 'Non')], default='def', max_length=3, verbose_name='Afficage du cadre de droite'),
+        ),
+    ]

+ 23 - 0
migrations/0024_auto_20240730_2235.py

@@ -0,0 +1,23 @@
+# Generated by Django 3.2.23 on 2024-07-30 20:35
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('core', '0023_auto_20240730_2056'),
+    ]
+
+    operations = [
+        migrations.RenameField(
+            model_name='page',
+            old_name='p_card_main_panel',
+            new_name='p_c_card_mp',
+        ),
+        migrations.RenameField(
+            model_name='page',
+            old_name='p_card_right_panel',
+            new_name='p_c_card_rp',
+        ),
+    ]

+ 23 - 0
migrations/0025_auto_20240730_2241.py

@@ -0,0 +1,23 @@
+# Generated by Django 3.2.23 on 2024-07-30 20:41
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('core', '0024_auto_20240730_2235'),
+    ]
+
+    operations = [
+        migrations.RenameField(
+            model_name='page',
+            old_name='p_c_card_mp',
+            new_name='c_card_mp',
+        ),
+        migrations.RenameField(
+            model_name='page',
+            old_name='p_c_card_rp',
+            new_name='c_card_rp',
+        ),
+    ]

+ 14 - 1
models.py

@@ -30,6 +30,12 @@ page_color = (
 	(u'white', u'Blanc'),
 )
 
+page_bordure = (
+	(u'def', u'Default'),
+	(u'oui', u'Oui'),
+	(u'non', u'Non'),
+)
+
 class Groupe (models.Model) : #group pour organisation
 	g_nom = models.CharField("Nom du groupe", max_length = 128, unique = True)
 	g_nom_slugify = models.CharField("Nom Slugify", max_length = 128, blank = True, editable = False)
@@ -102,7 +108,10 @@ class Page (models.Model) : #Architecture pour les pages static est dynamique
 	p_groupe = models.BooleanField("Afficher les groupes", default = False)
 	p_speedial = models.BooleanField("Afficher le Speedial", default = False)
 	p_publier = models.BooleanField("Publié", default = False)
+	p_proteger = models.BooleanField("Disponible que si authentifier", default = False)
 	p_see_title_and_des_in_templates = models.BooleanField("Description et titre visible dans les templates", default = True)
+	c_card_mp = models.CharField("Afficage du cadre central",choices=page_bordure, max_length=3, default='def')
+	c_card_rp = models.CharField("Afficage du cadre de droite",choices=page_bordure, max_length=3, default='def')
 
 	class Meta :
 		verbose_name = 'Gestion des pages'
@@ -110,7 +119,11 @@ class Page (models.Model) : #Architecture pour les pages static est dynamique
 		ordering = ['p_adresse']
 
 	def save(self, *args, **kwargs) :
-		self.p_titre_slugify = slugify(self.p_titre)
+		if self.p_type == "sys" and self.p_titre_slugify == "":
+			self.p_titre_slugify = slugify(self.p_titre)
+		elif self.p_type != "sys":
+			self.p_titre_slugify = slugify(self.p_titre)
+
 		if self.p_type == "lien":
 			self.p_description = "."
 			self.p_contenu = "."

+ 3 - 3
templates/base.html

@@ -48,13 +48,13 @@
 			<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fas fa-bars" ></i> {{ p_menu_parent.grouper }}</a>
 				<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
 				{% for item in p_menu_parent.list|dictsortreversed:"p_menu_poid" %}
-					<a class="dropdown-item" {%if item.p_type == "lien_ext" %}target="_blank"{% endif %}  href="{{item.p_adresse}}">{% if item.p_icone %}<i class="{{item.p_icone}}" ></i> {% endif %}{{item.p_titre}}</a></li>
+					<a class="dropdown-item {% if item.p_proteger == True and user.is_authenticated %} {% elif item.p_proteger == False %} {% else %}disabled{% endif %}" {%if item.p_type == "lien_ext" %}target="_blank"{% endif %} href="{{item.p_adresse}}">{% if item.p_icone %}<i class="{{item.p_icone}}" ></i> {% endif %}{{item.p_titre}}</a></li>
 				{% endfor %}
 				</div>
 			</div>
 			{% else %}
 				{% for item in p_menu_parent.list %}
-					<li class="nav-item"><a class="nav-link" {%if item.p_type == "lien_ext" %}target="_blank"{% endif %}  href="{{item.p_adresse}}">{% if item.p_icone %}<i class="{{item.p_icone}}" ></i> {% endif %}{{item.p_titre}}</a></li>
+					<li class="nav-item"><a class="nav-link {% if item.p_proteger == True and user.is_authenticated %} {% elif item.p_proteger == False %} {% else %}disabled{% endif %}" {%if item.p_type == "lien_ext" %}target="_blank"{% endif %} href="{{item.p_adresse}}">{% if item.p_icone %}<i class="{{item.p_icone}}" ></i> {% endif %}{{item.p_titre}}</a></li>
 				{% endfor %}
 			{% endif %}
 		{% endfor %}
@@ -139,7 +139,7 @@
 		</div>
 		<div class="col-lg-3 p-lg-1 p-md-0 mb-sm-1">
 			{% if page.c_card_rp == 'True'%}<div class="card" style="background-color: rgba(250,250,250,0.88);" >{% endif %}
-			{% if page.c_includ_rp != 'None'%}{% include page.c_includ_rp %}{% endif %}
+			{% comment %} {% if page.c_includ_rp != 'None'%}{% include page.c_includ_rp %}{% endif %} {% endcomment %}
 			{% block right_panel %}
 			{% endblock %}
 			{% if not request.user.is_authenticated and page.p_right and not "account/" in request.path %}

+ 3 - 3
templates/base_no_card.html

@@ -50,13 +50,13 @@
 			<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fas fa-bars" ></i> {{ p_menu_parent.grouper }}</a>
 				<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
 				{% for item in p_menu_parent.list|dictsortreversed:"p_menu_poid" %}
-					<a class="dropdown-item" {%if item.p_type == "lien_ext" %}target="_blank"{% endif %}  href="{{item.p_adresse}}">{% if item.p_icone %}<i class="{{item.p_icone}}" ></i> {% endif %}{{item.p_titre}}</a></li>
+					<a class="dropdown-item {% if item.p_proteger == True and user.is_authenticated %} {% elif item.p_proteger == False %} {% else %}disabled{% endif %}" {%if item.p_type == "lien_ext" %}target="_blank"{% endif %} href="{{item.p_adresse}}">{% if item.p_icone %}<i class="{{item.p_icone}}" ></i> {% endif %}{{item.p_titre}}</a></li>
 				{% endfor %}
 				</div>
 			</div>
 			{% else %}
 				{% for item in p_menu_parent.list %}
-					<li class="nav-item"><a class="nav-link" {%if item.p_type == "lien_ext" %}target="_blank"{% endif %}  href="{{item.p_adresse}}">{% if item.p_icone %}<i class="{{item.p_icone}}" ></i> {% endif %}{{item.p_titre}}</a></li>
+					<li class="nav-item"><a class="nav-link {% if item.p_proteger == True and user.is_authenticated %} {% elif item.p_proteger == False %} {% else %}disabled{% endif %}" {%if item.p_type == "lien_ext" %}target="_blank"{% endif %} href="{{item.p_adresse}}">{% if item.p_icone %}<i class="{{item.p_icone}}" ></i> {% endif %}{{item.p_titre}}</a></li>
 				{% endfor %}
 			{% endif %}
 		{% endfor %}
@@ -142,7 +142,7 @@
 		
 		<div class="col-lg-3 p-lg-1 p-md-0 mb-sm-1">
 			{% if page.c_card_rp == 'True'%}<div class="card" style="background-color: rgba(250,250,250,0.88);" >{% endif %}
-			{% if page.c_includ_rp != 'None'%}{% include page.c_includ_rp %}{% endif %}
+			{% comment %} {% if page.c_includ_rp != 'None'%}{% include page.c_includ_rp %}{% endif %} {% endcomment %}
 			{% block right_panel %}
 			{% endblock %}
 			{% if not request.user.is_authenticated and page.p_right and not "account/" in request.path %}

+ 22 - 23
templates/login.html

@@ -3,36 +3,35 @@
 {% load crispy_forms_tags %}
 
 {% block main %}
-{% if request.user.is_authenticated %}
-	<div class="card text-white bg-secondary m-5">
-	<div class="card-header">Oups ! </div>
-	<div class="card-body">
-		<p class="card-text">
-			Pardon, mais vous étés déjà connecté. <a href="{% url 'core_index' %}">Retourné à accueil</a>
-		</p>
-		</div>
-	</div>
-{% else %}
-		<div class="card text-white bg-secondary m-5">
-	<div class="card-header">Aide</div>
-	<div class="card-body">
-		<p class="card-text">
-			Merci de vous connecter en utilisant vos informations de connexion liée à votre ouverture de session.
-		</p>
+<div class="col-lg-10 p-0 mb-1">
+	<div class="card text-white bg-secondary m-lg-5">
+		{% if request.user.is_authenticated %}
+		<div class="card-header">Oups ! </div>
+		<div class="card-body">
+			<p class="card-text">
+				Pardon, mais vous étés déjà connecté. <a href="{% url 'core_index' %}">Retourné à accueil</a>
+			</p>
 		</div>
+		{% else %}
+		<div class="card-header">Connection</div>
+		<div class="card-body">
+			<form method="post">{% csrf_token %}
+				{{ form|crispy }}
+				<input type="submit" class="btn btn-success" value="Se connecter">
+			</form>
+		</div>	
+		{% endif %}
 	</div>
-
-{% endif %}
+</div>
 {% endblock %}
 
 {% block right_panel %}
 	<div class="card text-white bg-dark m-0">
-		<div class="card-header">Connection</div>
+		<div class="card-header">Aide</div>
 		<div class="card-body">
-		<form method="post">{% csrf_token %}
-			{{ form|crispy }}
-			<input type="submit" class="btn btn-success" value="Se connecter">
-		</form>
+			<p class="card-text">
+				Merci de vous connecter en utilisant vos informations de connexion liée à votre ouverture de session.
+			</p>
 		</div>
 	</div>
 {% endblock %}

+ 13 - 55
views.py

@@ -53,61 +53,9 @@ def get_data_value(name):
 		data = Data.objects.get(d_titre_slugify = name)
 	except:
 		data = Data()
-		if name == "site-name":
-			data.d_titre = name
-			data.d_type = "txt"
-			data.d_variable = "Duhaz Core"
-			data.save()
-		elif name == "site-logo":
-			data.d_titre = name
-			data.d_type = "txt"
-			data.d_variable = "far fa-clone"
-			data.save()
-		elif name == "site-version":
-			data.d_titre = name
-			data.d_type = "txt"
-			data.d_variable = "Jan. 2024"
-			data.save()
-		elif name == "background-color":
-			data.d_titre = name
-			data.d_type = "txt"
-			data.d_variable = "#999"
-			data.save()
-		elif name == "background":
-			data.d_titre = name
-			data.d_type = "txt"
-			data.d_variable = "background.jpeg"
-			data.save()
-		elif name == "background-logo":
-			data.d_titre = name
-			data.d_type = "txt"
-			data.d_variable = "logo-txt-Mrduhaz.png"
-			data.save()
-		elif name == "login-menu":
-			data.d_titre = name
-			data.d_type = "txt"
-			data.d_variable = "True"
-			data.save()
-		elif name == "includ-right-panel":
-			data.d_titre = name
-			data.d_type = "txt"
-			data.d_variable = "None"
-			data.save()
-		elif name == "card-main-panel":
-			data.d_titre = name
-			data.d_type = "txt"
-			data.d_variable = "True"
-			data.save()
-		elif name == "card-right-panel":
-			data.d_titre = name
-			data.d_type = "txt"
-			data.d_variable = "True"
-			data.save()
-		else :
-			data.d_variable = "Blop"
+		data.d_variable = "Blop"
 	return data.d_variable
 
-
 def update_data_value(name, value):
 	try:
 		data = Data.objects.get(d_titre_slugify = name)
@@ -161,8 +109,18 @@ def gen_page_sys(p_titre_slugify):
 	page.c_bgimagelogo = get_data_value('background-logo')
 	page.c_menulogin = get_data_value('login-menu')
 	page.c_includ_rp = get_data_value('includ-right-panel')
-	page.c_card_mp = get_data_value('card-main-panel')
-	page.c_card_rp = get_data_value('card-right-panel')
+	if page.c_card_mp == "non":
+		page.c_card_mp = False
+	elif page.c_card_mp == "oui":
+		page.c_card_mp = True
+	else :
+		page.c_card_mp = get_data_value('card-main-panel')
+	if page.c_card_rp == "non":
+		page.c_card_rp = "False"
+	elif page.c_card_rp == "oui":
+		page.c_card_rp = "True"
+	else :
+		page.c_card_rp = get_data_value('card-right-panel')
 	
 	return page