This commit is contained in:
Marwan Alwali 2025-02-10 14:42:07 +03:00
parent 7379bb9e4d
commit 53d7db0bfc
17 changed files with 90 additions and 45 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -1,6 +1,6 @@
from django import forms from django import forms
from django.utils.translation import get_language from django.utils.translation import get_language
from django.urls import reverse, reverse_lazy
class AddClassMixin: class AddClassMixin:
""" """
@ -40,4 +40,27 @@ class LocalizedNameMixin:
# form.save() # form.save()
# return super().form_valid(form) # return super().form_valid(form)
# else: # else:
# return form.errors # return form.errors
class BaseDateNavigationUrlMixIn:
BASE_DATE_URL_KWARGS = (
'entity_slug',
'unit_slug',
'ledger_pk',
'account_pk',
'coa_slug'
)
def get_context_data(self, **kwargs):
context = super(BaseDateNavigationUrlMixIn, self).get_context_data(**kwargs)
self.get_base_date_nav_url(context)
return context
def get_base_date_nav_url(self, context, **kwargs):
view_name = context['view'].request.resolver_match.url_name
view_name_base = '-'.join(view_name.split('-')[:2])
context['date_navigation_url'] = reverse(
view_name_base,
kwargs={
k: v for k, v in self.kwargs.items() if
k in self.BASE_DATE_URL_KWARGS
})

View File

@ -325,4 +325,25 @@ def number_to_words_arabic(number):
# if language == 'ar': # if language == 'ar':
# return number_to_words_arabic(number) # return number_to_words_arabic(number)
# else: # else:
# return number_to_words_english(number) # return number_to_words_english(number)
@register.inclusion_tag('components/date_picker.html', takes_context=True)
def date_picker(context, nav_url=None, date_picker_id=None):
try:
entity_slug = context['view'].kwargs.get('entity_slug')
except KeyError:
entity_slug = context['entity_slug']
if not date_picker_id:
date_picker_id = f'djl-datepicker-{randint(10000, 99999)}'
if 'date_picker_ids' not in context:
context['date_picker_ids'] = list()
context['date_picker_ids'].append(date_picker_id)
date_navigation_url = nav_url if nav_url else context.get('date_navigation_url')
return {
'entity_slug': entity_slug,
'date_picker_id': date_picker_id,
'date_navigation_url': date_navigation_url
}

View File

@ -439,21 +439,23 @@ class AjaxHandlerView(LoginRequiredMixin, View):
model_id = request.GET.get("model_id") model_id = request.GET.get("model_id")
year = request.GET.get("year") year = request.GET.get("year")
if not model_id or not year: model_id = int(model_id)
return JsonResponse( year = int(year)
{"error": "Missing required parameters: model_id or year"}, status=400
) query = Q(id_car_model=model_id) & (
Q(year_begin__lte=year, year_end__gte=year) |
Q(year_end__isnull=True) |
Q(year_begin__isnull=True)
)
try: try:
model_id = int(model_id) series = models.CarSerie.objects.filter(query).values(
year = int(year) "id_car_serie",
except ValueError: "name",
return JsonResponse({"error": "Invalid year format"}, status=400) "arabic_name",
"generation_name"
series = models.CarSerie.objects.filter( )
id_car_model=model_id,year_begin__lte = year, year_end__gte = year except Exception as e:
).values("id_car_serie", "name", "arabic_name", "generation_name") return JsonResponse({"error": "Server error occurred"}, status=500)
#
return JsonResponse(list(series), safe=False) return JsonResponse(list(series), safe=False)
def get_trims(self, request): def get_trims(self, request):

Binary file not shown.

View File

@ -7470,27 +7470,18 @@ msgid "Not set."
msgstr "غير محدد" msgstr "غير محدد"
#: venv/lib/python3.11/site-packages/appointment/utils/date_time.py:84 #: venv/lib/python3.11/site-packages/appointment/utils/date_time.py:84
#, fuzzy, python-format
#| msgid "%(count)d day"
#| msgid_plural "%(count)d days"
msgid "%(count)d day" msgid "%(count)d day"
msgid_plural "%(count)d days" msgid_plural "%(count)d days"
msgstr[0] "%(num)d يوم" msgstr[0] "%(num)d يوم"
msgstr[1] "%(num)d أيام" msgstr[1] "%(num)d أيام"
#: venv/lib/python3.11/site-packages/appointment/utils/date_time.py:88 #: venv/lib/python3.11/site-packages/appointment/utils/date_time.py:88
#, fuzzy, python-format
#| msgid "%(count)d hour"
#| msgid_plural "%(count)d hours"
msgid "%(count)d hour" msgid "%(count)d hour"
msgid_plural "%(count)d hours" msgid_plural "%(count)d hours"
msgstr[0] "%(num)d ساعة" msgstr[0] "%(num)d ساعة"
msgstr[1] "%(num)d ساعات" msgstr[1] "%(num)d ساعات"
#: venv/lib/python3.11/site-packages/appointment/utils/date_time.py:92 #: venv/lib/python3.11/site-packages/appointment/utils/date_time.py:92
#, fuzzy, python-format
#| msgid "%(count)d minute"
#| msgid_plural "%(count)d minutes"
msgid "%(count)d minute" msgid "%(count)d minute"
msgid_plural "%(count)d minutes" msgid_plural "%(count)d minutes"
msgstr[0] "%(num)d دقيقة" msgstr[0] "%(num)d دقيقة"
@ -8921,62 +8912,62 @@ msgstr "ديسمبر"
#: venv/lib/python3.11/site-packages/django/utils/dates.py:53 #: venv/lib/python3.11/site-packages/django/utils/dates.py:53
msgctxt "abbrev. month" msgctxt "abbrev. month"
msgid "Jan." msgid "Jan."
msgstr "يناير." msgstr "يناير"
#: venv/lib/python3.11/site-packages/django/utils/dates.py:54 #: venv/lib/python3.11/site-packages/django/utils/dates.py:54
msgctxt "abbrev. month" msgctxt "abbrev. month"
msgid "Feb." msgid "Feb."
msgstr "فبراير." msgstr "فبراير"
#: venv/lib/python3.11/site-packages/django/utils/dates.py:55 #: venv/lib/python3.11/site-packages/django/utils/dates.py:55
msgctxt "abbrev. month" msgctxt "abbrev. month"
msgid "March" msgid "March"
msgstr "مارس." msgstr "مارس"
#: venv/lib/python3.11/site-packages/django/utils/dates.py:56 #: venv/lib/python3.11/site-packages/django/utils/dates.py:56
msgctxt "abbrev. month" msgctxt "abbrev. month"
msgid "April" msgid "April"
msgstr "أبريل." msgstr "أبريل"
#: venv/lib/python3.11/site-packages/django/utils/dates.py:57 #: venv/lib/python3.11/site-packages/django/utils/dates.py:57
msgctxt "abbrev. month" msgctxt "abbrev. month"
msgid "May" msgid "May"
msgstr "مايو." msgstr "مايو"
#: venv/lib/python3.11/site-packages/django/utils/dates.py:58 #: venv/lib/python3.11/site-packages/django/utils/dates.py:58
msgctxt "abbrev. month" msgctxt "abbrev. month"
msgid "June" msgid "June"
msgstr "يونيو." msgstr "يونيو"
#: venv/lib/python3.11/site-packages/django/utils/dates.py:59 #: venv/lib/python3.11/site-packages/django/utils/dates.py:59
msgctxt "abbrev. month" msgctxt "abbrev. month"
msgid "July" msgid "July"
msgstr "يوليو." msgstr "يوليو"
#: venv/lib/python3.11/site-packages/django/utils/dates.py:60 #: venv/lib/python3.11/site-packages/django/utils/dates.py:60
msgctxt "abbrev. month" msgctxt "abbrev. month"
msgid "Aug." msgid "Aug."
msgstr "أغسطس." msgstr "أغسطس"
#: venv/lib/python3.11/site-packages/django/utils/dates.py:61 #: venv/lib/python3.11/site-packages/django/utils/dates.py:61
msgctxt "abbrev. month" msgctxt "abbrev. month"
msgid "Sept." msgid "Sept."
msgstr "سبتمبر." msgstr "سبتمبر"
#: venv/lib/python3.11/site-packages/django/utils/dates.py:62 #: venv/lib/python3.11/site-packages/django/utils/dates.py:62
msgctxt "abbrev. month" msgctxt "abbrev. month"
msgid "Oct." msgid "Oct."
msgstr "أكتوبر." msgstr "أكتوبر"
#: venv/lib/python3.11/site-packages/django/utils/dates.py:63 #: venv/lib/python3.11/site-packages/django/utils/dates.py:63
msgctxt "abbrev. month" msgctxt "abbrev. month"
msgid "Nov." msgid "Nov."
msgstr "نوفمبر." msgstr "نوفمبر"
#: venv/lib/python3.11/site-packages/django/utils/dates.py:64 #: venv/lib/python3.11/site-packages/django/utils/dates.py:64
msgctxt "abbrev. month" msgctxt "abbrev. month"
msgid "Dec." msgid "Dec."
msgstr "ديسمبر." msgstr "ديسمبر"
#: venv/lib/python3.11/site-packages/django/utils/dates.py:67 #: venv/lib/python3.11/site-packages/django/utils/dates.py:67
msgctxt "alt. month" msgctxt "alt. month"

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

View File

@ -106,7 +106,7 @@ function notify(tag,msg){
</main> </main>
{% block customJS %} {% block customJS %}
<script src="{% static 'django_ledger/bundle/djetler.bundle.js' %}"></script> <script src="{% static 'js/djetler.bundle.js' %}"></script>
<script src="{% static 'js/js-utils.js' %}"></script> <script src="{% static 'js/js-utils.js' %}"></script>
<script src="{% static 'js/modal/show_modal.js' %}"></script> <script src="{% static 'js/modal/show_modal.js' %}"></script>

View File

@ -0,0 +1,7 @@
{% load i18n %}
{% if date_navigation_url %}
<button id="{{ date_picker_id }}" data-baseurl="{{ date_navigation_url }}"
class="button is-small is-rounded is-dark is-outlined">{% trans 'Select Date' %}</button>
{% endif %}

View File

@ -1,4 +1,5 @@
{% load django_ledger %} {% load django_ledger %}
{% load i18n %} {% load i18n %}
<div class="card shadow-sm"> <div class="card shadow-sm">
@ -17,15 +18,15 @@
<div class="text-center mb-3"> <div class="text-center mb-3">
<p class="mb-1"> <p class="mb-1">
<span class="fw-bold">Year: </span> <span class="fw-bold">{{ _("Year") }}: </span>
<a href="{{ previous_year_url }}" class="text-decoration-none me-2"> <a href="{{ previous_year_url }}" class="text-decoration-none me-2">
<span class="fas fa-chevron-left"> </span> <span class="fas fa-chevron-right"> </span>
<span class="fas fa-chevron-left"> </span> <span class="fas fa-chevron-right"> </span>
{{ previous_year }}</a> {{ previous_year }}</a>
<a href="{{ current_year_url }}" class="text-decoration-none me-2 fw-bolder">{{ year }}</a> <a href="{{ current_year_url }}" class="text-decoration-none me-2 fw-bolder">{{ year }}</a>
<a href="{{ next_year_url }}" class="text-decoration-none">{{ next_year }} <a href="{{ next_year_url }}" class="text-decoration-none">{{ next_year }}
<span class="fas fa-chevron-right"> </span> <span class="fas fa-chevron-left"> </span>
<span class="fas fa-chevron-right"> </span> <span class="fas fa-chevron-left"> </span>
</a> </a>
</p> </p>
</div> </div>

View File

@ -32,7 +32,7 @@
<h2 class="display-4 font-weight-light"> <h2 class="display-4 font-weight-light">
{% if quarter %}{{ year }} | Q{{ quarter }} {% if quarter %}{{ year }} | Q{{ quarter }}
{% elif month %}{{ start_date | date:'F, Y' }} {% elif month %}{{ start_date | date:'F, Y' }}
{% else %}Fiscal Year {{ year }} {% else %}{{ _("Fiscal Year")}} {{ year }}
{% endif %}</h2> {% endif %}</h2>
<h3 class="h4 font-italic font-weight-light"> <h3 class="h4 font-italic font-weight-light">
{{ from_date | date:'m/d/Y' }} - {{ to_date | date:'m/d/Y' }} {{ from_date | date:'m/d/Y' }} - {{ to_date | date:'m/d/Y' }}