From e7e2153ab4fa1530cf58f660e14ce3cca3c5730b Mon Sep 17 00:00:00 2001 From: Nanoy Date: Mon, 18 Feb 2019 19:20:09 +0100 Subject: [PATCH] Ajout des documents --- .gitignore | 1 + coopeV3/settings.py | 4 ++ coopeV3/templatetags/vip.py | 26 ++++++++++- coopeV3/urls.py | 4 +- .../migrations/0008_auto_20190218_1802.py | 43 +++++++++++++++++++ preferences/models.py | 3 ++ .../preferences/general_preferences.html | 37 +++++++++++++++- preferences/views.py | 2 +- templates/footer.html | 9 ++++ 9 files changed, 124 insertions(+), 5 deletions(-) create mode 100644 preferences/migrations/0008_auto_20190218_1802.py diff --git a/.gitignore b/.gitignore index b6332fc..80eb75b 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,4 @@ tags venv static/ Pipfile +mediafiles diff --git a/coopeV3/settings.py b/coopeV3/settings.py index cea493e..ed16024 100644 --- a/coopeV3/settings.py +++ b/coopeV3/settings.py @@ -124,3 +124,7 @@ STATICFILES_DIRS = [ STATIC_ROOT = os.path.join(BASE_DIR, 'static') LOGIN_URL = '/users/login' + +MEDIA_ROOT = 'mediafiles/' +MEDIA_URL = '/media/' + diff --git a/coopeV3/templatetags/vip.py b/coopeV3/templatetags/vip.py index 436cb03..aa7f9c3 100644 --- a/coopeV3/templatetags/vip.py +++ b/coopeV3/templatetags/vip.py @@ -44,4 +44,28 @@ def global_message(): def logout_time(): gp, _ = GeneralPreferences.objects.get_or_create(pk=1) logout_time = gp.automatic_logout_time - return logout_time \ No newline at end of file + return logout_time + +@register.simple_tag +def statutes(): + gp,_ = GeneralPreferences.objects.get_or_create(pk=1) + try: + return '' + str(gp.statutes) + '' + except: + return "Pas de document" + +@register.simple_tag +def rules(): + gp,_ = GeneralPreferences.objects.get_or_create(pk=1) + try: + return '' + str(gp.rules) + '' + except: + return "Pas de document" + +@register.simple_tag +def menu(): + gp,_ = GeneralPreferences.objects.get_or_create(pk=1) + try: + return '' + str(gp.menu) + '' + except: + return "Pas de document" diff --git a/coopeV3/urls.py b/coopeV3/urls.py index ec4148f..a4768a3 100644 --- a/coopeV3/urls.py +++ b/coopeV3/urls.py @@ -15,6 +15,8 @@ Including another URLconf """ from django.contrib import admin from django.urls import path, include +from django.conf.urls.static import static +from django.conf import settings from . import views @@ -27,4 +29,4 @@ urlpatterns = [ path('users/', include('users.urls')), path('gestion/', include('gestion.urls')), path('preferences/', include('preferences.urls')), -] +] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/preferences/migrations/0008_auto_20190218_1802.py b/preferences/migrations/0008_auto_20190218_1802.py new file mode 100644 index 0000000..2dad7cc --- /dev/null +++ b/preferences/migrations/0008_auto_20190218_1802.py @@ -0,0 +1,43 @@ +# Generated by Django 2.1 on 2019-02-18 17:02 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('preferences', '0007_auto_20190120_1208'), + ] + + operations = [ + migrations.AddField( + model_name='generalpreferences', + name='menu', + field=models.FileField(blank=True, null=True, upload_to=''), + ), + migrations.AddField( + model_name='generalpreferences', + name='rules', + field=models.FileField(blank=True, null=True, upload_to=''), + ), + migrations.AddField( + model_name='generalpreferences', + name='statutes', + field=models.FileField(blank=True, null=True, upload_to=''), + ), + migrations.AddField( + model_name='historicalgeneralpreferences', + name='menu', + field=models.TextField(blank=True, max_length=100, null=True), + ), + migrations.AddField( + model_name='historicalgeneralpreferences', + name='rules', + field=models.TextField(blank=True, max_length=100, null=True), + ), + migrations.AddField( + model_name='historicalgeneralpreferences', + name='statutes', + field=models.TextField(blank=True, max_length=100, null=True), + ), + ] diff --git a/preferences/models.py b/preferences/models.py index f4d1ce6..ec5f357 100644 --- a/preferences/models.py +++ b/preferences/models.py @@ -36,6 +36,9 @@ class GeneralPreferences(models.Model): floating_buttons = models.BooleanField(default=False) home_text = models.TextField(blank=True) automatic_logout_time = models.PositiveIntegerField(null=True) + statutes = models.FileField(blank=True, null=True) + rules = models.FileField(blank=True, null=True) + menu = models.FileField(blank=True, null=True) history = HistoricalRecords() class Cotisation(models.Model): diff --git a/preferences/templates/preferences/general_preferences.html b/preferences/templates/preferences/general_preferences.html index 5c1e047..18b22b6 100644 --- a/preferences/templates/preferences/general_preferences.html +++ b/preferences/templates/preferences/general_preferences.html @@ -6,12 +6,13 @@
  • Site actif
  • Bureau
  • Suivi de pintes
  • -
  • Autre
  • +
  • Documents
  • +
  • Autre
  • {% endblock %} {% block content %} -
    + {% csrf_token %}
    @@ -122,6 +123,38 @@
    +
    +
    +
    +

    Documents

    +
    +
    +
    + {{form.statutes}} + +
    +
    +
    +
    + {{form.rules}} + +
    +
    +
    +
    + {{form.menu}} + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    diff --git a/preferences/views.py b/preferences/views.py index e8bae46..e5a3f7a 100644 --- a/preferences/views.py +++ b/preferences/views.py @@ -30,7 +30,7 @@ def generalPreferences(request): :template:`preferences/general_preferences.html` """ gp,_ = GeneralPreferences.objects.get_or_create(pk=1) - form = GeneralPreferencesForm(request.POST or None, instance=gp) + form = GeneralPreferencesForm(request.POST or None, request.FILES or None, instance=gp) if(form.is_valid()): form.save() messages.success(request, "Les préférences générales ont bien été mises à jour") diff --git a/templates/footer.html b/templates/footer.html index 3606600..2ec24d4 100644 --- a/templates/footer.html +++ b/templates/footer.html @@ -2,6 +2,15 @@

    À propos

    L'association Coopé Technopôle Metz (CTM) est une association de droit local dont le siège social est établi à la résidence Edouard Branly. Son but est d'entretenir un lieu convivial sous la forme d'un bar associatif. Les membres actifs sont les coopemen (ou coopewomen).

    +

    Documents utiles

    +
    +
    Statuts
    +
    {% autoescape off %}{% statutes %}{% endautoescape %}
    +
    Règlement intérieur
    +
    {% autoescape off %}{% rules %}{% endautoescape %}
    +
    Carte
    +
    {% autoescape off %}{% menu %}{% endautoescape %}
    +

    Contacts