Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Base de données Mediatek
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mediatek
Base de données Mediatek
Commits
aca1d2de
Verified
Commit
aca1d2de
authored
Aug 10, 2019
by
erdnaxe
🦋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge index views
parent
be96a61f
Pipeline
#1406
failed with stage
in 3 minutes and 9 seconds
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
189 additions
and
27 deletions
+189
-27
README.md
README.md
+1
-1
med/admin.py
med/admin.py
+29
-0
med/urls.py
med/urls.py
+3
-3
media/admin.py
media/admin.py
+5
-5
media/views.py
media/views.py
+6
-7
theme/templates/admin/base_site.html
theme/templates/admin/base_site.html
+8
-8
theme/templates/admin/index.html
theme/templates/admin/index.html
+133
-0
users/admin.py
users/admin.py
+4
-3
No files found.
README.md
View file @
aca1d2de
...
...
@@ -9,7 +9,7 @@ Elle permet de gérer les medias, bd, jeux, emprunts, ainsi que les adhérents d
## Licence
Ce projet est sous la licence GNU public license v
2
.0.
Ce projet est sous la licence GNU public license v
3
.0.
## Développement
...
...
med/admin.py
0 → 100644
View file @
aca1d2de
# -*- mode: python; coding: utf-8 -*-
# Copyright (C) 2017-2019 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
from
django.contrib.admin
import
AdminSite
from
django.utils.translation
import
gettext_lazy
as
_
from
django.views.decorators.cache
import
never_cache
from
media.models
import
Emprunt
class
DatabaseAdmin
(
AdminSite
):
index_title
=
_
(
'Welcome to the Mediatek database'
)
@
never_cache
def
index
(
self
,
request
,
extra_context
=
None
):
"""
Add borrowed item to admin index
"""
response
=
super
().
index
(
request
,
extra_context
)
# User is always authenticated
user_borrowed
=
Emprunt
.
objects
.
filter
(
user
=
request
.
user
)
response
.
context_data
[
"borrowed_items"
]
=
user_borrowed
return
response
admin_site
=
DatabaseAdmin
()
med/urls.py
View file @
aca1d2de
...
...
@@ -3,11 +3,11 @@
# SPDX-License-Identifier: GPL-3.0-or-later
from
django.conf.urls
import
include
,
url
from
django.contrib
import
admin
from
django.contrib.auth.views
import
password_reset
from
django.views.generic
import
RedirectView
from
media.views
import
index
from
.admin
import
admin_site
urlpatterns
=
[
url
(
r
'^$'
,
index
,
name
=
'index'
),
...
...
@@ -24,6 +24,6 @@ urlpatterns = [
url
(
r
'^accounts/'
,
include
(
'django.contrib.auth.urls'
)),
url
(
r
'^accounts/profile/'
,
RedirectView
.
as_view
(
pattern_name
=
'index'
)),
url
(
r
'^
admin
/doc/'
,
include
(
'django.contrib.admindocs.urls'
)),
url
(
r
'^
admin/'
,
admin
.
site
.
urls
),
url
(
r
'^
database
/doc/'
,
include
(
'django.contrib.admindocs.urls'
)),
url
(
r
'^
database/'
,
admin_
site
.
urls
),
]
media/admin.py
View file @
aca1d2de
...
...
@@ -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
)
media/views.py
View file @
aca1d2de
...
...
@@ -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 w
ith user's borrowed items
Home page w
hich 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'
),
})
theme/templates/admin/base_site.html
View file @
aca1d2de
...
...
@@ -25,10 +25,9 @@ SPDX-License-Identifier: GPL-3.0-or-later
{% endif %}
{% endblock %}
{% block userlinks %}
{% if user.is_authenticated %}
{% if available_apps %}
{# When in admin site, list all admin pages and documentation #}
<span
class=
"dropdown"
>
{% if available_apps %}
{# When in admin site, list all admin pages and documentation #}
<span
class=
"dropdown"
>
<a
href=
"{% url 'admin:index' %}"
>
{% trans 'Explore database' %}
</a>
<span
class=
"dropdown-content"
>
{% for app in available_apps %}
...
...
@@ -47,10 +46,11 @@ SPDX-License-Identifier: GPL-3.0-or-later
{% endif %}
</span>
</span>
/
{% elif user.is_staff %}
{# When not in admin site, but user is staff then add a link #}
<a
href=
"{% url 'admin:index' %}"
>
{% trans 'Explore database' %}
</a>
/
{% endif %}
{% else %}
{# When not in admin site, but user is staff then add a link #}
<a
href=
"{% url 'admin:index' %}"
>
{% trans 'Explore database' %}
</a>
/
{% endif %}
{% if user.is_authenticated %}
<a
href=
"{% url 'logout' %}"
>
{% trans 'Log out' %}
</a>
{% else %}
<a
href=
"{% url 'login' %}"
>
{% trans 'Log in' %}
</a>
...
...
media/templates/media
/index.html
→
theme/templates/admin
/index.html
View file @
aca1d2de
{% extends "admin/
base_site
.html" %}
{% extends "admin/
index
.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>
<h2>
Welcome to procrastination haven !
</h2>
<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>
{% if app_list %}
{% for app in app_list %}
<div
class=
"app-{{ app.app_label }} module"
>
<table>
<caption>
<a
href=
"{{ app.app_url }}"
class=
"section"
title=
"{% blocktrans with name=app.name %}Models in the {{ name }} application{% endblocktrans %}"
>
{{ app.name }}
</a>
</caption>
{% for model in app.models %}
<tr
class=
"model-{{ model.object_name|lower }}"
>
{% if model.admin_url %}
<th
scope=
"row"
><a
href=
"{{ model.admin_url }}"
>
{{ model.name }}
</a></th>
{% else %}
<th
scope=
"row"
>
{{ model.name }}
</th>
{% endif %}
{% if model.add_url %}
<td><a
href=
"{{ model.add_url }}"
class=
"addlink"
>
{% trans 'Add' %}
</a></td>
{% else %}
<td>
</td>
{% endif %}
{% if model.admin_url %}
<td><a
href=
"{{ model.admin_url }}"
class=
"changelink"
>
{% trans 'Change' %}
</a></td>
{% else %}
<td>
</td>
{% endif %}
</tr>
{% endfor %}
</table>
</div>
{% endfor %}
{% endif %}
<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"
>
...
...
@@ -51,7 +73,8 @@ SPDX-License-Identifier: GPL-3.0-or-later
<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 '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>
:
...
...
@@ -73,9 +96,38 @@ SPDX-License-Identifier: GPL-3.0-or-later
{% else %}
<p>
{% trans 'No current borrowed items.' %}
</p>
{% endif %}
<h3>
{% trans 'My actions' %}
</h3>
{% load log %}
{% get_admin_log 10 as admin_log for_user user %}
{% if not admin_log %}
<p>
{% trans 'None available' %}
</p>
{% else %}
<ul
class=
"actionlist"
>
{% for entry in admin_log %}
<li
class=
"{% if entry.is_addition %}addlink{% endif %}{% if entry.is_change %}changelink{% endif %}{% if entry.is_deletion %}deletelink{% endif %}"
>
{% if entry.is_deletion or not entry.get_admin_url %}
{{ entry.object_repr }}
{% else %}
<a
href=
"{{ entry.get_admin_url }}"
>
{{ entry.object_repr }}
</a>
{% endif %}
<br/>
{% if entry.content_type %}
<span
class=
"mini quiet"
>
{% filter capfirst %}
{{ entry.content_type }}{% endfilter %}
</span>
{% else %}
<span
class=
"mini quiet"
>
{% trans 'Unknown content' %}
</span>
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
{% else %}
<p>
{% trans 'You are not logged in.' %}
</p>
{% endif %}
</div>
</div>
{% endblock %}
users/admin.py
View file @
aca1d2de
...
...
@@ -13,6 +13,7 @@ from reversion.admin import VersionAdmin
from
.forms
import
UserCreationAdminForm
from
.models
import
Adhesion
,
Clef
,
User
from
med.admin
import
admin_site
class
ClefAdmin
(
VersionAdmin
):
...
...
@@ -122,6 +123,6 @@ class UserAdmin(VersionAdmin, BaseUserAdmin):
actions_btn
.
allow_tags
=
True
admin
.
site
.
register
(
User
,
UserAdmin
)
admin
.
site
.
register
(
Adhesion
,
AdhesionAdmin
)
admin
.
site
.
register
(
Clef
,
ClefAdmin
)
admin
_
site
.
register
(
User
,
UserAdmin
)
admin
_
site
.
register
(
Adhesion
,
AdhesionAdmin
)
admin
_
site
.
register
(
Clef
,
ClefAdmin
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment