3
0
Fork 0
mirror of https://github.com/nanoy42/coope synced 2024-11-05 01:16:28 +00:00

Ajout des documents

This commit is contained in:
Yoann Pétri 2019-02-18 19:20:09 +01:00
parent a25970e8b6
commit e7e2153ab4
9 changed files with 124 additions and 5 deletions

1
.gitignore vendored
View file

@ -43,3 +43,4 @@ tags
venv venv
static/ static/
Pipfile Pipfile
mediafiles

View file

@ -124,3 +124,7 @@ STATICFILES_DIRS = [
STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_ROOT = os.path.join(BASE_DIR, 'static')
LOGIN_URL = '/users/login' LOGIN_URL = '/users/login'
MEDIA_ROOT = 'mediafiles/'
MEDIA_URL = '/media/'

View file

@ -45,3 +45,27 @@ def logout_time():
gp, _ = GeneralPreferences.objects.get_or_create(pk=1) gp, _ = GeneralPreferences.objects.get_or_create(pk=1)
logout_time = gp.automatic_logout_time logout_time = gp.automatic_logout_time
return logout_time return logout_time
@register.simple_tag
def statutes():
gp,_ = GeneralPreferences.objects.get_or_create(pk=1)
try:
return '<a target="_blank" href="' + gp.statutes.url + '">' + str(gp.statutes) + '</a>'
except:
return "Pas de document"
@register.simple_tag
def rules():
gp,_ = GeneralPreferences.objects.get_or_create(pk=1)
try:
return '<a target="_blank" href="' + gp.rules.url + '">' + str(gp.rules) + '</a>'
except:
return "Pas de document"
@register.simple_tag
def menu():
gp,_ = GeneralPreferences.objects.get_or_create(pk=1)
try:
return '<a target="_blank" href="' + gp.menu.url + '">' + str(gp.menu) + '</a>'
except:
return "Pas de document"

View file

@ -15,6 +15,8 @@ Including another URLconf
""" """
from django.contrib import admin from django.contrib import admin
from django.urls import path, include from django.urls import path, include
from django.conf.urls.static import static
from django.conf import settings
from . import views from . import views
@ -27,4 +29,4 @@ urlpatterns = [
path('users/', include('users.urls')), path('users/', include('users.urls')),
path('gestion/', include('gestion.urls')), path('gestion/', include('gestion.urls')),
path('preferences/', include('preferences.urls')), path('preferences/', include('preferences.urls')),
] ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

View file

@ -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),
),
]

View file

@ -36,6 +36,9 @@ class GeneralPreferences(models.Model):
floating_buttons = models.BooleanField(default=False) floating_buttons = models.BooleanField(default=False)
home_text = models.TextField(blank=True) home_text = models.TextField(blank=True)
automatic_logout_time = models.PositiveIntegerField(null=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() history = HistoricalRecords()
class Cotisation(models.Model): class Cotisation(models.Model):

View file

@ -6,12 +6,13 @@
<li><a href="#second">Site actif</a></li> <li><a href="#second">Site actif</a></li>
<li><a href="#third">Bureau</a></li> <li><a href="#third">Bureau</a></li>
<li><a href="#fourth">Suivi de pintes</a></li> <li><a href="#fourth">Suivi de pintes</a></li>
<li><a href="fifth">Autre</a></li> <li><a href="#fifth">Documents</a></li>
<li><a href="#sixth">Autre</a></li>
</ul> </ul>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<form class="main" method="post" action=""> <form class="main" method="post" action="" enctype="multipart/form-data">
{% csrf_token %} {% csrf_token %}
<section id="first" class="main"> <section id="first" class="main">
<div class="spotlight"> <div class="spotlight">
@ -122,6 +123,38 @@
</div> </div>
</section> </section>
<section id="fifth" class="main"> <section id="fifth" class="main">
<div class="spotlight">
<div class="content">
<header class="major">
<h2>Documents</h2>
</header>
<div class="row uniform">
<div class="12u">
{{form.statutes}}
<label for="{{form.statutes.id_for_label}}">Statuts</label>
</div>
</div>
<div class="row uniform">
<div class="12u">
{{form.rules}}
<label for="{{form.rules.id_for_label}}">Règlement intérieur</label>
</div>
</div>
<div class="row uniform">
<div class="12u">
{{form.menu}}
<label for="{{form.menu.id_for_label}}">Menu / Carte</label>
</div>
</div>
<div class="row uniform">
<div class="12u">
<button type="submit"><i class="fa fa-save"></i> Enregistrer</button>
</div>
</div>
</div>
</div>
</section>
<section id="sixth" class="main">
<div class="spotlight"> <div class="spotlight">
<div class="content"> <div class="content">
<header class="major"> <header class="major">

View file

@ -30,7 +30,7 @@ def generalPreferences(request):
:template:`preferences/general_preferences.html` :template:`preferences/general_preferences.html`
""" """
gp,_ = GeneralPreferences.objects.get_or_create(pk=1) 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()): if(form.is_valid()):
form.save() form.save()
messages.success(request, "Les préférences générales ont bien été mises à jour") messages.success(request, "Les préférences générales ont bien été mises à jour")

View file

@ -2,6 +2,15 @@
<section> <section>
<h2>À propos</h2> <h2>À propos</h2>
<p>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).</p> <p>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).</p>
<h2>Documents utiles</h2>
<dl class="alt">
<dt>Statuts</dt>
<dd>{% autoescape off %}{% statutes %}{% endautoescape %}</dd>
<dt>Règlement intérieur</dt>
<dd>{% autoescape off %}{% rules %}{% endautoescape %}</dd>
<dt>Carte</dt>
<dd>{% autoescape off %}{% menu %}{% endautoescape %}</dd>
</dl>
</section> </section>
<section> <section>
<h2>Contacts</h2> <h2>Contacts</h2>