Compare commits
2 commits
5d50953482
...
0a140eca15
Author | SHA1 | Date | |
---|---|---|---|
|
0a140eca15 | ||
|
c376aea787 |
|
@ -14,7 +14,8 @@ class AgendaAdmin(admin.ModelAdmin):
|
|||
|
||||
@admin.register(Document)
|
||||
class DocumentAdmin(admin.ModelAdmin):
|
||||
list_display = ["titre", "quand", "prive"]
|
||||
list_display = ["titre", "quand", "categorie", "prive"]
|
||||
list_filter = ["categorie"]
|
||||
ordering = ["-quand"]
|
||||
|
||||
|
||||
|
|
17
beesgospel/migrations/0004_document_categorie.py
Normal file
17
beesgospel/migrations/0004_document_categorie.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('beesgospel', '0003_membre_annee_entree_date_naissance'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='document',
|
||||
name='categorie',
|
||||
field=models.CharField(choices=[('video', 'Vidéo'), ('audio', 'Audio'), ('photos', 'Photos'), ('doc', 'Document')], default='doc', max_length=30, verbose_name='Catégorie'),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
|
@ -63,11 +63,18 @@ class Agenda(models.Model):
|
|||
|
||||
|
||||
class Document(models.Model):
|
||||
class Categories(models.TextChoices):
|
||||
VIDEO = "video", "Vidéo"
|
||||
AUDIO = "audio", "Audio"
|
||||
PHOTOS = "photos", "Photos"
|
||||
DOCUMENT = "doc", "Document"
|
||||
|
||||
fichier = models.FileField("Fichier", upload_to="documents", blank=True)
|
||||
url = models.URLField("URL", blank=True)
|
||||
quand = models.DateField("Date")
|
||||
titre = models.CharField("Titre", max_length=150)
|
||||
infos = models.TextField("Infos", blank=True)
|
||||
categorie = models.CharField("Catégorie", max_length=30, choices=Categories)
|
||||
prive = models.BooleanField(
|
||||
"Privé", default=False, help_text=(
|
||||
"Un document privé ne peut être consulté que par les membres de "
|
||||
|
|
|
@ -45,12 +45,19 @@ class AgendaView(ListView):
|
|||
class MediaView(ListView):
|
||||
model = Document
|
||||
template_name = "media.html"
|
||||
prive = False
|
||||
|
||||
def get_queryset(self):
|
||||
qs = Document.objects.all().order_by("-quand", "titre")
|
||||
if not self.request.user.is_authenticated:
|
||||
qs = qs.filter(prive=False)
|
||||
return qs
|
||||
return Document.objects.filter(prive=self.prive).order_by("-quand", "titre")
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
return {
|
||||
**super().get_context_data(**kwargs),
|
||||
"title": {
|
||||
False: "Enregistrements, photos et vidéos de la chorale",
|
||||
True: "Documents privés",
|
||||
}.get(self.prive)
|
||||
}
|
||||
|
||||
|
||||
class EspaceMembresView(LoginRequiredMixin, TemplateView):
|
||||
|
|
|
@ -11,8 +11,9 @@ urlpatterns = [
|
|||
path("v2", TemplateView.as_view(template_name="index2.html"), name="home"),
|
||||
path("presentation/", views.PresentationView.as_view(), name="presentation"),
|
||||
path("contact/", TemplateView.as_view(template_name="contact.html"), name="contact"),
|
||||
path("agenda/", views.AgendaView.as_view(), name="agenda"),
|
||||
path("medias/", views.MediaView.as_view(prive=False), name="medias"),
|
||||
path("membres/", views.EspaceMembresView.as_view(), name="membres"),
|
||||
path("membres/liste/", views.ListeMembresView.as_view(), name="liste-membres"),
|
||||
path("agenda/", views.AgendaView.as_view(), name="agenda"),
|
||||
path("medias/", views.MediaView.as_view(), name="medias"),
|
||||
path("membres/documents/", views.MediaView.as_view(prive=True), name="docs-membres"),
|
||||
]
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
{% block page_title %} - Media{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h2 class="mb-5">Enregistrements, photos et vidéos de la chorale</h2>
|
||||
<h2 class="mb-5">{{ title }}</h2>
|
||||
|
||||
{% for item in object_list %}
|
||||
<div class="border-bottom border-danger mt-3{% if item.prive %} prive{% endif %}">
|
||||
|
@ -20,4 +20,8 @@
|
|||
{% empty %}
|
||||
<p><i>Aucun document disponible pour le moment</i></p>
|
||||
{% endfor %}
|
||||
|
||||
{% if perms.beesgospel.change_document %}
|
||||
<p class="text-danger"><a href="{% url 'admin:beesgospel_document_changelist' %}">Gestion des documents</a></p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -7,11 +7,9 @@
|
|||
<h2>Espace membres</h2>
|
||||
<div class="row mt-4">
|
||||
<div class="col col-4"><a href="{% url 'liste-membres' %}">Liste des membres</a></div>
|
||||
<div class="col col-4"><a href="{% url 'docs-membres' %}">Documents pour les membres</a></div>
|
||||
{% if perms.beesgospel.change_agenda %}
|
||||
<div class="col col-4"><a href="{% url 'admin:beesgospel_agenda_changelist' %}">Gestion de l’agenda</a></div>
|
||||
{% endif %}
|
||||
{% if perms.beesgospel.change_document %}
|
||||
<div class="col col-4"><a href="{% url 'admin:beesgospel_document_changelist' %}">Gestion des documents</a></div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in a new issue