mirror of
https://gitlab.crans.org/mediatek/med.git
synced 2025-06-29 22:31:10 +02:00
Merge index views
This commit is contained in:
@ -2,9 +2,9 @@
|
||||
# Copyright (C) 2017-2019 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from django.contrib import admin
|
||||
from reversion.admin import VersionAdmin
|
||||
|
||||
from med.admin import admin_site
|
||||
from .models import Auteur, Emprunt, Jeu, Media
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ class JeuAdmin(VersionAdmin):
|
||||
'nombre_joueurs_max', 'comment')
|
||||
|
||||
|
||||
admin.site.register(Auteur, AuteurAdmin)
|
||||
admin.site.register(Media, MediaAdmin)
|
||||
admin.site.register(Emprunt, EmpruntAdmin)
|
||||
admin.site.register(Jeu, JeuAdmin)
|
||||
admin_site.register(Auteur, AuteurAdmin)
|
||||
admin_site.register(Media, MediaAdmin)
|
||||
admin_site.register(Emprunt, EmpruntAdmin)
|
||||
admin_site.register(Jeu, JeuAdmin)
|
||||
|
@ -1,81 +0,0 @@
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% comment %}
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
{% endcomment %}
|
||||
|
||||
{% load i18n static %}
|
||||
|
||||
{% block title %}Base de donnée de la Mediatek{% endblock %}
|
||||
|
||||
{% block extrastyle %}
|
||||
{{ block.super }}
|
||||
<link rel="stylesheet" type="text/css" href="{% static "admin/css/dashboard.css" %}"/>
|
||||
{% endblock %}
|
||||
|
||||
{% block coltype %}colMS{% endblock %}
|
||||
|
||||
{% block bodyclass %}{{ block.super }} dashboard{% endblock %}
|
||||
|
||||
{% block breadcrumbs %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div id="content-main">
|
||||
<h1>Bienvenue sur la base de données de la Mediatek.</h1>
|
||||
<h1>Welcome to procrastination heaven !</h1>
|
||||
<p>
|
||||
Le site va subir progressivement des mises à jour pendant ces vacances.
|
||||
Si vous rencontrez des instabilités,
|
||||
veuillez nous faire remonter les problèmes <a href="mailto:a@crans.org,club-med@crans.org">au webmaster</a>.
|
||||
</p>
|
||||
<img src="{% static "images/splash.png" %}" class="poulpy" alt="Poulpy">
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
<div id="content-related">
|
||||
<div class="module" id="recent-actions-module">
|
||||
{% if user.is_authenticated %}
|
||||
<h2>{{ user.first_name }} {{ user.last_name }}</h2>
|
||||
|
||||
<h3>
|
||||
{% trans 'My profile' %}
|
||||
<small><a class="changelink" href="{% url 'users:edit-info' %}">
|
||||
{% trans 'Edit' %}
|
||||
</a></small>
|
||||
</h3>
|
||||
<ul>
|
||||
<li><strong>{% trans 'username' %}</strong> : {{ user.username }}</li>
|
||||
<li><strong>{% trans 'email' %}</strong> : {{ user.email }}</li>
|
||||
<li><strong>{% trans 'comment' %}</strong> : {{ user.comment }}</li>
|
||||
<li><strong>{% trans 'date joined' %}</strong> : {{ user.date_joined }}</li>
|
||||
<li><strong>{% trans 'last login' %}</strong> : {{ user.last_login }}</li>
|
||||
<li><strong>{% trans 'address' %}</strong> : {{ user.address }}</li>
|
||||
<li><strong>{% trans 'phone number' %}</strong> : {{ user.telephone }}</li>
|
||||
<li><strong>{% trans 'groups' %}</strong> : {% for g in user.groups.all %}{{ g.name }} {% endfor %}</li>
|
||||
<li><strong>{% trans 'maximum borrowed' %}</strong> : {{ user.maxemprunt }}</li>
|
||||
<li>
|
||||
<strong>{% trans 'membership for current year' %}</strong> :
|
||||
{% if user.is_adherent %}
|
||||
<span style="color:green">{% trans 'yes' %}</span>
|
||||
{% else %}
|
||||
<span style="color:red">{% trans 'no' %}</span>
|
||||
{% endif %}
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>{% trans 'Current borrowed items' %}</h3>
|
||||
{% if borrowed_items %}
|
||||
<ul>
|
||||
{% for emprunt in borrowed_items %}
|
||||
<li>{{ emprunt.media }} ({% trans 'since' %} {{ emprunt.date_emprunt }})</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p>{% trans 'No current borrowed items.' %}</p>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<p>{% trans 'You are not logged in.' %}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
@ -8,6 +8,7 @@ from django.db import transaction
|
||||
from django.shortcuts import redirect, render
|
||||
from django.template.context_processors import csrf
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from reversion import revisions as reversion
|
||||
|
||||
from users.models import User
|
||||
@ -70,13 +71,11 @@ def retour_emprunt(request, empruntid):
|
||||
|
||||
def index(request):
|
||||
"""
|
||||
Home page with user's borrowed items
|
||||
Home page which redirect to admin when logged in
|
||||
"""
|
||||
if request.user.is_authenticated:
|
||||
borrowed_items = Emprunt.objects.filter(user=request.user)
|
||||
return redirect('admin:index')
|
||||
else:
|
||||
borrowed_items = []
|
||||
|
||||
return render(request, 'media/index.html', {
|
||||
'borrowed_items': borrowed_items,
|
||||
})
|
||||
return render(request, 'admin/index.html', {
|
||||
'title': _('Welcome to the Mediatek database'),
|
||||
})
|
||||
|
Reference in New Issue
Block a user