customized admin styling, added get_absolute_url for Note model,

added inline in Sujet admin to show FicheStatistique
This commit is contained in:
artus40
2017-08-31 19:57:55 +02:00
parent 3cb6140417
commit f91d94685d
9 changed files with 384 additions and 21 deletions

View File

@@ -1,15 +1,24 @@
from django.contrib import admin from django.contrib import admin
from .models import * from .models import *
from statistiques.models import FicheStatistique
# Register your models here. # Register your models here.
class FicheStatistiqueInline(admin.StackedInline):
model = FicheStatistique
can_delete = False
@admin.register(Sujet) @admin.register(Sujet)
class SujetAdmin(admin.ModelAdmin): class SujetAdmin(admin.ModelAdmin):
fieldsets = [ fieldsets = [
('Identité', {'fields': [('nom', 'prenom'), 'genre']}), ('Identité', {'fields': [('nom', 'surnom', 'prenom', ), ('genre', 'age')]}),
('Informations', {'fields': ['age', ]}), ]
inlines = [
FicheStatistiqueInline,
] ]

View File

@@ -2,7 +2,7 @@ import logging
from django.utils import timezone from django.utils import timezone
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.urls import reverse from django.shortcuts import reverse
from django.db import models from django.db import models
from . import managers from . import managers
@@ -176,3 +176,6 @@ class Note(models.Model):
return getter return getter
bg_colors = property(cached_attr('bg_colors'), doc="background color of header") bg_colors = property(cached_attr('bg_colors'), doc="background color of header")
labels = property(cached_attr('labels'), doc="list of string to display as labels") labels = property(cached_attr('labels'), doc="list of string to display as labels")
def get_absolute_url(self):
return reverse("notes:details-sujet", kwargs={"pk": self.sujet.pk})

View File

@@ -1,3 +1,4 @@
from django.contrib import admin from django.contrib import admin
# Register your models here. # Register your models here.

View File

@@ -84,3 +84,9 @@ class FicheStatistique(models.Model):
completed += 1 completed += 1
percentage = int(completed / len(observed) * 100) percentage = int(completed / len(observed) * 100)
return percentage return percentage
def __str__(self):
return "<Statistiques: %s>" % self.sujet
class Meta:
verbose_name = "Fiche statistique"

View File

@@ -3,7 +3,7 @@
{% get_current_language as LANGUAGE_CODE %}{% get_current_language_bidi as LANGUAGE_BIDI %} {% get_current_language as LANGUAGE_CODE %}{% get_current_language_bidi as LANGUAGE_BIDI %}
{% block extrastyle %} {% block extrastyle %}
<link rel="stylesheet" type="text/css" href="{% block stylesheet %}{% static "css/base-admin.css" %}{% endblock %}" /> <link rel="stylesheet" type="text/css" href="{% block stylesheet %}{% static "css/admin/base.css" %}{% endblock %}" />
{% if LANGUAGE_BIDI %}<link rel="stylesheet" type="text/css" href="{% block stylesheet_rtl %}{% static "admin/css/rtl.css" %}{% endblock %}" />{% endif %} {% if LANGUAGE_BIDI %}<link rel="stylesheet" type="text/css" href="{% block stylesheet_rtl %}{% static "admin/css/rtl.css" %}{% endblock %}" />{% endif %}
{% endblock %} {% endblock %}

View File

@@ -3,7 +3,7 @@
{% block extrastyle %} {% block extrastyle %}
{{ block.super }} {{ block.super }}
<link rel="stylesheet" type="text/css" href="{% static "admin/css/changelists.css" %}" /> <link rel="stylesheet" type="text/css" href="{% static "css/admin/changelists.css" %}" />
{% if cl.formset %} {% if cl.formset %}
<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}" /> <link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}" />
{% endif %} {% endif %}

View File

@@ -3,9 +3,9 @@
{% if show_save %}<button type="submit" class="btn btn-primary" name="_save">{% bootstrap_icon "save" %} {% trans 'Save' %}</button>{% endif %} {% if show_save %}<button type="submit" class="btn btn-primary" name="_save">{% bootstrap_icon "save" %} {% trans 'Save' %}</button>{% endif %}
{% if show_delete_link %} {% if show_delete_link %}
{% url opts|admin_urlname:'delete' original.pk|admin_urlquote as delete_url %} {% url opts|admin_urlname:'delete' original.pk|admin_urlquote as delete_url %}
<p class="deletelink-box"><a href="{% add_preserved_filters delete_url %}" class="btn btn-warning">{% bootstrap_icon "remove" %}{% trans "Delete" %}</a></p> <p class="deletelink-box"><a href="{% add_preserved_filters delete_url %}" class="btn btn-danger">{% bootstrap_icon "remove" %} {% trans "Delete" %}</a></p>
{% endif %} {% endif %}
{% if show_save_as_new %}<button type="submit" class="btn btn-default" value="{% trans 'Save as new' %}" name="_saveasnew" />{% endif %} {% if show_save_as_new %}<button type="submit" class="btn btn-default" name="_saveasnew">{% trans 'Save as new' %}</button>{% endif %}
{% if show_save_and_add_another %}<button type="submit" class="btn btn-default" name="_addanother">{% bootstrap_icon "plus" %} {% trans 'Save and add another' %}</button>{% endif %} {% if show_save_and_add_another %}<button type="submit" class="btn btn-default" name="_addanother">{% bootstrap_icon "plus" %} {% trans 'Save and add another' %}</button>{% endif %}
{% if show_save_and_continue %}<button type="submit" class="btn btn-default" name="_continue">{% bootstrap_icon "floppy-save" %} {% trans 'Save and continue editing' %}</button>{% endif %} {% if show_save_and_continue %}<button type="submit" class="btn btn-default" name="_continue">{% bootstrap_icon "floppy-save" %} {% trans 'Save and continue editing' %}</button>{% endif %}
</div> </div>

View File

@@ -17,7 +17,7 @@ body {
/* LINKS */ /* LINKS */
a:link, a:visited { /*a:link, a:visited {
color: #447e9b; color: #447e9b;
text-decoration: none; text-decoration: none;
} }
@@ -32,7 +32,7 @@ a:focus {
a img { a img {
border: none; border: none;
} }*/
a.section:link, a.section:visited { a.section:link, a.section:visited {
color: #fff; color: #fff;
@@ -361,7 +361,7 @@ table thead th.sorted .sortoptions a {
width: 14px; width: 14px;
height: 14px; height: 14px;
display: inline-block; display: inline-block;
background: url(../admin/img/sorting-icons.svg) 0 0 no-repeat; background: url(../../admin/img/sorting-icons.svg) 0 0 no-repeat;
background-size: 14px auto; background-size: 14px auto;
} }
@@ -521,7 +521,7 @@ input[type=button][disabled].default {
font-weight: 400; font-weight: 400;
font-size: 13px; font-size: 13px;
text-align: left; text-align: left;
background: #79aec8; background: #2f2f2f;
color: #fff; color: #fff;
} }
@@ -549,18 +549,18 @@ ul.messagelist li {
font-size: 13px; font-size: 13px;
padding: 10px 10px 10px 65px; padding: 10px 10px 10px 65px;
margin: 0 0 10px 0; margin: 0 0 10px 0;
background: #dfd url(../admin/img/icon-yes.svg) 40px 12px no-repeat; background: #dfd url(../../admin/img/icon-yes.svg) 40px 12px no-repeat;
background-size: 16px auto; background-size: 16px auto;
color: #333; color: #333;
} }
ul.messagelist li.warning { ul.messagelist li.warning {
background: #ffc url(../admin/img/icon-alert.svg) 40px 14px no-repeat; background: #ffc url(../../admin/img/icon-alert.svg) 40px 14px no-repeat;
background-size: 14px auto; background-size: 14px auto;
} }
ul.messagelist li.error { ul.messagelist li.error {
background: #ffefef url(../admin/img/icon-no.svg) 40px 12px no-repeat; background: #ffefef url(../../admin/img/icon-no.svg) 40px 12px no-repeat;
background-size: 16px auto; background-size: 16px auto;
} }
@@ -634,7 +634,7 @@ div.system-message p.system-message-title {
padding: 4px 5px 4px 25px; padding: 4px 5px 4px 25px;
margin: 0; margin: 0;
color: #c11; color: #c11;
background: #ffefef url(../admin/img/icon-no.svg) 5px 5px no-repeat; background: #ffefef url(../../admin/img/icon-no.svg) 5px 5px no-repeat;
} }
.description { .description {
@@ -665,17 +665,17 @@ div.breadcrumbs a:focus, div.breadcrumbs a:hover {
.addlink { .addlink {
padding-left: 16px; padding-left: 16px;
background: url(../admin/img/icon-addlink.svg) 0 1px no-repeat; background: url(../../admin/img/icon-addlink.svg) 0 1px no-repeat;
} }
.changelink, .inlinechangelink { .changelink, .inlinechangelink {
padding-left: 16px; padding-left: 16px;
background: url(../admin/img/icon-changelink.svg) 0 1px no-repeat; background: url(../../admin/img/icon-changelink.svg) 0 1px no-repeat;
} }
.deletelink { .deletelink {
padding-left: 16px; padding-left: 16px;
background: url(../admin/img/icon-deletelink.svg) 0 1px no-repeat; background: url(../../admin/img/icon-deletelink.svg) 0 1px no-repeat;
} }
a.deletelink:link, a.deletelink:visited { a.deletelink:link, a.deletelink:visited {
@@ -744,11 +744,11 @@ a.deletelink:focus, a.deletelink:hover {
} }
.object-tools a.viewsitelink, .object-tools a.golink { .object-tools a.viewsitelink, .object-tools a.golink {
background-image: url(../admin/img/tooltag-arrowright.svg); background-image: url(../../admin/img/tooltag-arrowright.svg);
} }
.object-tools a.addlink { .object-tools a.addlink {
background-image: url(../admin/img/tooltag-add.svg); background-image: url(../../admin/img/tooltag-add.svg);
} }
/* OBJECT HISTORY */ /* OBJECT HISTORY */

View File

@@ -0,0 +1,344 @@
/* CHANGELISTS */
#changelist {
position: relative;
width: 100%;
}
#changelist table {
width: 100%;
}
.change-list .hiddenfields { display:none; }
.change-list .filtered table {
border-right: none;
}
.change-list .filtered {
min-height: 400px;
}
.change-list .filtered .results, .change-list .filtered .paginator,
.filtered #toolbar, .filtered div.xfull {
margin-right: 280px;
width: auto;
}
.change-list .filtered table tbody th {
padding-right: 1em;
}
#changelist-form .results {
overflow-x: auto;
}
#changelist .toplinks {
border-bottom: 1px solid #ddd;
}
#changelist .paginator {
color: #666;
border-bottom: 1px solid #eee;
background: #fff;
overflow: hidden;
}
/* CHANGELIST TABLES */
#changelist table thead th {
padding: 0;
white-space: nowrap;
vertical-align: middle;
}
#changelist table thead th.action-checkbox-column {
width: 1.5em;
text-align: center;
}
#changelist table tbody td.action-checkbox {
text-align: center;
}
#changelist table tfoot {
color: #666;
}
/* TOOLBAR */
#changelist #toolbar {
padding: 8px 10px;
margin-bottom: 15px;
border-top: 1px solid #eee;
border-bottom: 1px solid #eee;
background: #f8f8f8;
color: #666;
}
#changelist #toolbar form input {
border-radius: 4px;
font-size: 14px;
padding: 5px;
color: #333;
}
#changelist #toolbar form #searchbar {
height: 19px;
border: 1px solid #ccc;
padding: 2px 5px;
margin: 0;
vertical-align: top;
font-size: 13px;
}
#changelist #toolbar form #searchbar:focus {
border-color: #999;
}
#changelist #toolbar form input[type="submit"] {
border: 1px solid #ccc;
padding: 2px 10px;
margin: 0;
vertical-align: middle;
background: #fff;
box-shadow: 0 -15px 20px -10px rgba(0, 0, 0, 0.15) inset;
cursor: pointer;
color: #333;
}
#changelist #toolbar form input[type="submit"]:focus,
#changelist #toolbar form input[type="submit"]:hover {
border-color: #999;
}
#changelist #changelist-search img {
vertical-align: middle;
margin-right: 4px;
}
/* FILTER COLUMN */
#changelist-filter {
position: absolute;
width: 240px;
background: #f8f8f8;
/*top: 0;
right: 0;
z-index: 1000;
border-left: none;
margin: 0;*/
}
#changelist-filter h2 {
font-size: 14px;
text-transform: uppercase;
letter-spacing: 0.5px;
padding: 5px 15px;
margin-bottom: 12px;
border-bottom: none;
}
#changelist-filter h3 {
font-weight: 400;
font-size: 14px;
padding: 0 15px;
margin-bottom: 10px;
}
#changelist-filter ul {
margin: 5px 0;
padding: 0 15px 15px;
border-bottom: 1px solid #eaeaea;
}
#changelist-filter ul:last-child {
border-bottom: none;
padding-bottom: none;
}
#changelist-filter li {
list-style-type: none;
margin-left: 0;
padding-left: 0;
}
#changelist-filter a {
display: block;
color: #999;
text-overflow: ellipsis;
overflow-x: hidden;
}
#changelist-filter li.selected {
border-left: 5px solid #eaeaea;
padding-left: 10px;
margin-left: -15px;
}
#changelist-filter li.selected a {
color: #5b80b2;
}
#changelist-filter a:focus, #changelist-filter a:hover,
#changelist-filter li.selected a:focus,
#changelist-filter li.selected a:hover {
color: #036;
}
/* DATE DRILLDOWN */
.change-list ul.toplinks {
display: block;
float: left;
padding: 0;
margin: 0;
width: 100%;
}
.change-list ul.toplinks li {
padding: 3px 6px;
font-weight: bold;
list-style-type: none;
display: inline-block;
}
.change-list ul.toplinks .date-back a {
color: #999;
}
.change-list ul.toplinks .date-back a:focus,
.change-list ul.toplinks .date-back a:hover {
color: #036;
}
/* PAGINATOR */
.paginator {
font-size: 13px;
padding-top: 10px;
padding-bottom: 10px;
line-height: 22px;
margin: 0;
border-top: 1px solid #ddd;
}
.paginator a:link, .paginator a:visited {
padding: 2px 6px;
background: #79aec8;
text-decoration: none;
color: #fff;
}
.paginator a.showall {
padding: 0;
border: none;
background: none;
color: #5b80b2;
}
.paginator a.showall:focus, .paginator a.showall:hover {
background: none;
color: #036;
}
.paginator .end {
margin-right: 6px;
}
.paginator .this-page {
padding: 2px 6px;
font-weight: bold;
font-size: 13px;
vertical-align: top;
}
.paginator a:focus, .paginator a:hover {
color: white;
background: #036;
}
/* ACTIONS */
.filtered .actions {
margin-right: 280px;
border-right: none;
}
#changelist table input {
margin: 0;
vertical-align: baseline;
}
#changelist table tbody tr.selected {
background-color: #FFFFCC;
}
#changelist .actions {
padding: 10px;
background: #fff;
border-top: none;
border-bottom: none;
line-height: 24px;
color: #999;
}
#changelist .actions.selected {
background: #fffccf;
border-top: 1px solid #fffee8;
border-bottom: 1px solid #edecd6;
}
#changelist .actions span.all,
#changelist .actions span.action-counter,
#changelist .actions span.clear,
#changelist .actions span.question {
font-size: 13px;
margin: 0 0.5em;
display: none;
}
#changelist .actions:last-child {
border-bottom: none;
}
#changelist .actions select {
vertical-align: top;
height: 24px;
background: none;
color: #000;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 14px;
padding: 0 0 0 4px;
margin: 0;
margin-left: 10px;
}
#changelist .actions select:focus {
border-color: #999;
}
#changelist .actions label {
display: inline-block;
vertical-align: middle;
font-size: 13px;
}
#changelist .actions .button {
font-size: 13px;
border: 1px solid #ccc;
border-radius: 4px;
background: #fff;
box-shadow: 0 -15px 20px -10px rgba(0, 0, 0, 0.15) inset;
cursor: pointer;
height: 24px;
line-height: 1;
padding: 4px 8px;
margin: 0;
color: #333;
}
#changelist .actions .button:focus, #changelist .actions .button:hover {
border-color: #999;
}