mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
Translate datepicker and add age limit to products
This commit is contained in:
@ -7,6 +7,8 @@ from django.core.exceptions import ValidationError
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.conf import settings
|
||||
from django.db import transaction
|
||||
from django.contrib.staticfiles.storage import staticfiles_storage
|
||||
from django.utils.html import escape
|
||||
from phonenumber_field.modelfields import PhoneNumberField
|
||||
|
||||
from datetime import datetime, timedelta, date
|
||||
@ -281,6 +283,12 @@ class User(AbstractBaseUser):
|
||||
return "%s (%s)" % (self.get_full_name(), self.nick_name)
|
||||
return self.get_full_name()
|
||||
|
||||
def get_age(self):
|
||||
"""
|
||||
Returns the age
|
||||
"""
|
||||
return timezone.now().year - self.date_of_birth.year
|
||||
|
||||
def email_user(self, subject, message, from_email=None, **kwargs):
|
||||
"""
|
||||
Sends an email to this User.
|
||||
@ -360,9 +368,9 @@ class User(AbstractBaseUser):
|
||||
<em>%s</em>
|
||||
</a>
|
||||
""" % (
|
||||
self.profile_pict.get_download_url() if self.profile_pict else "/static/core/img/na.gif",
|
||||
self.profile_pict.get_download_url() if self.profile_pict else staticfiles_storage.url("core/img/na.gif"),
|
||||
_("Profile"),
|
||||
self.get_display_name(),
|
||||
escape(self.get_display_name()),
|
||||
)
|
||||
|
||||
|
||||
|
@ -35,8 +35,4 @@ $( function() {
|
||||
popup.html('<iframe src="/file/popup" width="100%" height="95%"></iframe><div id="file_id" value="null" />');
|
||||
popup.dialog({title: $(this).text()}).dialog( "open" );
|
||||
});
|
||||
$('.select_date').datepicker({
|
||||
changeMonth: true,
|
||||
changeYear: true
|
||||
});
|
||||
} );
|
||||
|
39
core/static/core/js/ui/i18n/datepicker-fr.js
Normal file
39
core/static/core/js/ui/i18n/datepicker-fr.js
Normal file
@ -0,0 +1,39 @@
|
||||
/* French initialisation for the jQuery UI date picker plugin. */
|
||||
/* Written by Keith Wood (kbwood{at}iinet.com.au),
|
||||
Stéphane Nahmani (sholby@sholby.net),
|
||||
Stéphane Raimbault <stephane.raimbault@gmail.com> */
|
||||
( function( factory ) {
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [ "../widgets/datepicker" ], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery.datepicker );
|
||||
}
|
||||
}( function( datepicker ) {
|
||||
|
||||
datepicker.regional.fr = {
|
||||
closeText: "Fermer",
|
||||
prevText: "Précédent",
|
||||
nextText: "Suivant",
|
||||
currentText: "Aujourd'hui",
|
||||
monthNames: [ "janvier", "février", "mars", "avril", "mai", "juin",
|
||||
"juillet", "août", "septembre", "octobre", "novembre", "décembre" ],
|
||||
monthNamesShort: [ "janv.", "févr.", "mars", "avr.", "mai", "juin",
|
||||
"juil.", "août", "sept.", "oct.", "nov.", "déc." ],
|
||||
dayNames: [ "dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi" ],
|
||||
dayNamesShort: [ "dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam." ],
|
||||
dayNamesMin: [ "D","L","M","M","J","V","S" ],
|
||||
weekHeader: "Sem.",
|
||||
dateFormat: "dd/mm/yy",
|
||||
firstDay: 1,
|
||||
isRTL: false,
|
||||
showMonthAfterYear: false,
|
||||
yearSuffix: "" };
|
||||
datepicker.setDefaults( datepicker.regional.fr );
|
||||
|
||||
return datepicker.regional.fr;
|
||||
|
||||
} ) );
|
@ -69,6 +69,7 @@
|
||||
{% block script %}
|
||||
<script src="{{ static('core/js/jquery-3.1.0.min.js') }}"></script>
|
||||
<script src="{{ static('core/js/ui/jquery-ui.min.js') }}"></script>
|
||||
<script src="{{ static('core/js/ui/i18n/datepicker-fr.js') }}"></script>
|
||||
<script src="{{ static('core/js/multiple-select.js') }}"></script>
|
||||
<script src="{{ static('ajax_select/js/ajax_select.js') }}"></script>
|
||||
<script src="{{ static('core/js/script.js') }}"></script>
|
||||
@ -85,6 +86,14 @@ $('.select_multiple').multipleSelect({
|
||||
position: 'top',
|
||||
{% endif %}
|
||||
});
|
||||
$('.select_date').datepicker({
|
||||
changeMonth: true,
|
||||
changeYear: true,
|
||||
dayNamesShort: $.datepicker.regional[ "{{ request.LANGUAGE_CODE }}" ].dayNamesShort,
|
||||
dayNames: $.datepicker.regional[ "{{ request.LANGUAGE_CODE }}" ].dayNames,
|
||||
monthNamesShort: $.datepicker.regional[ "{{ request.LANGUAGE_CODE }}" ].monthNamesShort,
|
||||
monthNames: $.datepicker.regional[ "{{ request.LANGUAGE_CODE }}" ].monthNames,
|
||||
}).datepicker( $.datepicker.regional[ "{{ request.LANGUAGE_CODE }}"] );
|
||||
</script>
|
||||
{% endblock %}
|
||||
</body>
|
||||
|
@ -4,15 +4,8 @@
|
||||
|
||||
{% macro user_link_with_pict(user) -%}
|
||||
<a href="{{ url("core:user_profile", user_id=user.id) }}" class="mini_profile_link" >
|
||||
<span>
|
||||
{% if user.profile_pict %}
|
||||
<img src="{{ user.profile_pict.get_download_url() }}" alt="{% trans %}Profile{% endtrans %}" />
|
||||
{% else %}
|
||||
<img src="{{ static('core/img/na.gif') }}" alt="{% trans %}Profile{% endtrans %}" />
|
||||
{% endif %}
|
||||
</span>
|
||||
<em>{{ user.get_display_name() }}</em>
|
||||
</a>
|
||||
{{ user.get_mini_item()|safe }}
|
||||
</a>
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro user_mini_profile(user) %}
|
||||
@ -27,7 +20,7 @@
|
||||
<p id="nickname">« {{ user.nick_name }} »</p>
|
||||
{% endif %}
|
||||
{% if user.date_of_birth %}
|
||||
<p>{% trans %}Born: {% endtrans %}{{ user.date_of_birth|date("d/m/Y") }}</p>
|
||||
<p>{% trans %}Born: {% endtrans %}{{ user.date_of_birth|date("d/m/Y") }} ({{ user.get_age() }})</p>
|
||||
{% endif %}
|
||||
{% if user.promo %}
|
||||
<p><img src="{{ static('core/img/promo_%02d.png' % user.promo) }}" alt="Promo {{ user.promo }}" class="promo_pict" />
|
||||
|
Reference in New Issue
Block a user