remove-useless-queries-counter-stats (#519)

This commit is contained in:
thomas girod
2023-03-24 15:32:05 +01:00
committed by GitHub
parent f0a08afd31
commit 6c1fa6de0b
10 changed files with 790 additions and 558 deletions

View File

@ -1198,18 +1198,38 @@ blockquote h5:first-child {
}
table {
width: 100%;
font-size: 0.9em;
width: 90%;
margin: 15px auto;
border-collapse: collapse;
border-spacing: 0;
border-radius: 5px;
-moz-border-radius: 5px;
overflow: hidden;
box-shadow: rgba(60, 64, 67, .3) 0 1px 3px 0, rgba(60, 64, 67, .15) 0 4px 8px 3px;
}
@media screen and (max-width: 500px){
table {
width: 100%;
}
}
th {
padding: 4px;
}
td, th {
vertical-align: middle;
text-align: center;
padding: 5px 10px;
> ul {
margin-top: 0;
}
}
td {
padding: 4px;
margin: 5px;
border: solid 1px $primary-neutral-color;
border-collapse: collapse;
vertical-align: top;
overflow: hidden;
@ -1219,18 +1239,29 @@ td {
}
}
th, thead td {
text-align: center;
border-top: none;
}
thead {
font-weight: bold;
background-color: #354a5f;
color: white;
}
tbody > tr {
&:nth-child(even) {
background: $primary-neutral-light-color;
}
&:hover {
&.clickable:hover {
cursor: pointer;
background: $secondary-neutral-light-color;
width: 100%;
}
&.highlight {
color: $primary-dark-color;
font-style: italic;
}
}
sup {
@ -2350,4 +2381,4 @@ $pedagogy-white-text: #f0f0f0;
}
}
}
}
}

View File

@ -5,8 +5,12 @@
{% trans user_name=profile.get_display_name() %}{{ user_name }}'s profile{% endtrans %}
{% endblock %}
{% block additional_js %}
<script src="{{ static('core/js/alpinejs.min.js') }}" defer></script>
{% endblock %}
{% block content %}
<div id="user_profile_page">
<div id="user_profile_page" x-data>
<div id="user_profile">
<!-- Profile -->
<div id="user_profile_infos">
@ -15,7 +19,7 @@
<div id="user_profile_infos_nick">&laquo; {{ profile.nick_name }} &raquo;</div>
{% endif %}
{% if profile.quote %}
<div id="user_profile_infos_quote">
@ -146,24 +150,35 @@
</div>
{% endif %}
{% if profile.was_subscribed and (user == profile or user.can_read_subscription_history)%}
<div id="drop_subscriptions">
<h5>{% trans %}Subscription history{% endtrans %}</h5>
<table>
<tr>
<th>{% trans %}Subscription start{% endtrans %}</th>
<th>{% trans %}Subscription end{% endtrans %}</th>
<th>{% trans %}Subscription type{% endtrans %}</th>
<th>{% trans %}Payment method{% endtrans %}</th>
</tr>
{% for sub in profile.subscriptions.all() %}
<tr>
<td>{{ sub.subscription_start }}</td>
<td>{{ sub.subscription_end }}</td>
<td>{{ sub.subscription_type }}</td>
<td>{{ sub.get_payment_method_display() }}</td>
</tr>
{% endfor %}
</table>
<div class="collapse" :class="{'shadow': collapsed}" x-data="{collapsed: false}" x-cloak>
<div class="collapse-header clickable" @click="collapsed = !collapsed">
<span class="collapse-header-text">
{% trans %}Subscription history{% endtrans %}
</span>
<span class="collapse-header-icon" :class="{'reverse': collapsed}">
<i class="fa fa-caret-down"></i>
</span>
</div>
<div class="collapse-body" x-show="collapsed" x-transition.scale.origin.top>
<table>
<thead>
<tr>
<th>{% trans %}Subscription start{% endtrans %}</th>
<th>{% trans %}Subscription end{% endtrans %}</th>
<th>{% trans %}Subscription type{% endtrans %}</th>
<th>{% trans %}Payment method{% endtrans %}</th>
</tr>
</thead>
{% for sub in profile.subscriptions.all() %}
<tr>
<td>{{ sub.subscription_start }}</td>
<td>{{ sub.subscription_end }}</td>
<td>{{ sub.subscription_type }}</td>
<td>{{ sub.get_payment_method_display() }}</td>
</tr>
{% endfor %}
</table>
</div>
</div>
{% endif %}
@ -177,13 +192,25 @@
<input type="submit" value="{% trans %}Give gift{% endtrans %}">
</form>
{% if profile.gifts.exists() %}
<br>
<div id="drop_gifts">
<h5>{% trans %}Last given gift :{% endtrans %} {{ profile.gifts.order_by('-date').first() }}</h5>
<div>
{% set gifts = profile.gifts.order_by("-date")|list %}
<br>
<div class="collapse" :class="{'shadow': collapsed}" x-data="{collapsed: false}" x-cloak>
<div class="collapse-header clickable" @click="collapsed = !collapsed">
<span class="collapse-header-text">
{% trans %}Last given gift :{% endtrans %} {{ gifts[0] }}
</span>
<span class="collapse-header-icon" :class="{'reverse': collapsed}">
<i class="fa fa-caret-down"></i>
</span>
</div>
<div class="collapse-body" x-show="collapsed" x-transition.scale.origin.top>
<ul>
{% for gift in profile.gifts.all().order_by('-date') %}
<li>{{ gift }} <a href="{{ url('core:user_gift_delete', user_id=profile.id, gift_id=gift.id) }}">{% trans %}Delete{% endtrans %}</a></li>
{% for gift in gifts %}
<li>{{ gift }}
<a href="{{ url('core:user_gift_delete', user_id=profile.id, gift_id=gift.id) }}">
<i class="fa fa-trash"></i>
</a>
</li>
{% endfor %}
</ul>
</div>
@ -229,12 +256,5 @@ $(function(){
active: false
});
});
$(function(){
$("#drop_subscriptions").accordion({
heightStyle: "content",
collapsible: true,
active: false
});
});
</script>
{% endblock %}

View File

@ -23,11 +23,13 @@
#
#
import datetime
import phonenumbers
from django import template
from django.template.defaultfilters import stringfilter
from django.utils.safestring import mark_safe
from django.utils.translation import ngettext
from core.scss.processor import ScssProcessor
from core.markdown import markdown as md
@ -54,41 +56,26 @@ def phonenumber(value, country="FR", format=phonenumbers.PhoneNumberFormat.NATIO
return value
@register.filter()
@stringfilter
def datetime_format_python_to_PHP(python_format_string):
"""
Given a python datetime format string, attempts to convert it to the nearest PHP datetime format string possible.
"""
python2PHP = {
"%a": "D",
"%a": "D",
"%A": "l",
"%b": "M",
"%B": "F",
"%c": "",
"%d": "d",
"%H": "H",
"%I": "h",
"%j": "z",
"%m": "m",
"%M": "i",
"%p": "A",
"%S": "s",
"%U": "",
"%w": "w",
"%W": "W",
"%x": "",
"%X": "",
"%y": "y",
"%Y": "Y",
"%Z": "e",
}
@register.filter(name="truncate_time")
def truncate_time(value, time_unit):
value = str(value)
return {
"millis": lambda: value.split(".")[0],
"seconds": lambda: value.rsplit(":", maxsplit=1)[0],
"minutes": lambda: value.split(":", maxsplit=1)[0],
"hours": lambda: value.rsplit(" ")[0],
}[time_unit]()
php_format_string = python_format_string
for py, php in python2PHP.items():
php_format_string = php_format_string.replace(py, php)
return php_format_string
@register.filter(name="format_timedelta")
def format_timedelta(value: datetime.timedelta) -> str:
days = value.days
if days == 0:
return str(value)
remainder = value - datetime.timedelta(days=days)
return ngettext(
"%(nb_days)d day, %(remainder)s", "%(nb_days)d days, %(remainder)s", days
) % {"nb_days": days, "remainder": str(remainder)}
@register.simple_tag()

View File

@ -31,7 +31,6 @@ from datetime import date
from PIL import ExifTags
# from exceptions import IOError
import PIL
from django.conf import settings
@ -52,14 +51,12 @@ def get_start_of_semester(d=date.today()):
year = today.year
start = date(year, settings.SITH_START_DATE[0], settings.SITH_START_DATE[1])
start2 = start.replace(month=(start.month + 6) % 12)
if start > start2:
start, start2 = start2, start
if today < start:
return start2.replace(year=year - 1)
elif today < start2:
return start
else:
return start2
spring, autumn = min(start, start2), max(start, start2)
if today > autumn: # autumn semester
return autumn
if today > spring: # spring semester
return spring
return autumn.replace(year=year - 1) # autumn semester of last year
def get_semester(d=date.today()):