home page
This commit is contained in:
parent
5077b20770
commit
4db2d5c0f8
18 changed files with 127 additions and 3 deletions
|
|
@ -50,6 +50,7 @@ INSTALLED_APPS = [
|
||||||
'jalali_date',
|
'jalali_date',
|
||||||
|
|
||||||
# local apps
|
# local apps
|
||||||
|
'apps.core',
|
||||||
'apps.users',
|
'apps.users',
|
||||||
'apps.gooyal_oauth2',
|
'apps.gooyal_oauth2',
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ urlpatterns = [
|
||||||
path('swagger/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='redoc'),
|
path('swagger/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='redoc'),
|
||||||
|
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
|
path('', include('apps.core.urls')),
|
||||||
path('users/', include('apps.users.urls')),
|
path('users/', include('apps.users.urls')),
|
||||||
path('oauth2/', include('apps.gooyal_oauth2.urls', namespace='gooyal_oauth2')),
|
path('oauth2/', include('apps.gooyal_oauth2.urls', namespace='gooyal_oauth2')),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
0
apps/core/__init__.py
Normal file
0
apps/core/__init__.py
Normal file
2
apps/core/admin.py
Normal file
2
apps/core/admin.py
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
6
apps/core/apps.py
Normal file
6
apps/core/apps.py
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class CoreConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
|
name = 'apps.core'
|
||||||
0
apps/core/migrations/__init__.py
Normal file
0
apps/core/migrations/__init__.py
Normal file
2
apps/core/models.py
Normal file
2
apps/core/models.py
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
from django.db import models
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
1
apps/core/templates/jalali_date/widgets/attrs.html
Normal file
1
apps/core/templates/jalali_date/widgets/attrs.html
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{% for name, value in widget.attrs.items %}{% if value is not False %} {{ name }}{% if value is not True %}="{{ value|stringformat:'s' }}"{% endif %}{% endif %}{% endfor %}
|
||||||
1
apps/core/templates/jalali_date/widgets/date.html
Normal file
1
apps/core/templates/jalali_date/widgets/date.html
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
<input type="{{ widget.type }}" name="{{ widget.name }}"{% if widget.value != None %} value="{{ widget.value|stringformat:'s' }}"{% endif %}{% include "django/forms/widgets/attrs.html" %} data-jdp>
|
||||||
0
apps/core/templatetags/__init__.py
Normal file
0
apps/core/templatetags/__init__.py
Normal file
30
apps/core/templatetags/tags.py
Normal file
30
apps/core/templatetags/tags.py
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
from django import template
|
||||||
|
import jdatetime
|
||||||
|
from django.core.paginator import Paginator
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
|
@register.filter(name="to_jalali")
|
||||||
|
def to_jalali(value):
|
||||||
|
if value:
|
||||||
|
return jdatetime.date.fromgregorian(date=value, locale='fa_IR').strftime("%Y/%m/%d")
|
||||||
|
else:
|
||||||
|
return value
|
||||||
|
|
||||||
|
@register.filter(name="amount_split_3digit")
|
||||||
|
def amount_split_3digit(value):
|
||||||
|
text = str(value)[::-1]
|
||||||
|
return ','.join([l[::-1] for l in [text[i:i + 3] for i in range(0, len(text), 3)][::-1]])
|
||||||
|
|
||||||
|
|
||||||
|
@register.simple_tag
|
||||||
|
def get_proper_elided_page_range(p, number, on_each_side=2, on_ends=2):
|
||||||
|
paginator = Paginator(p.object_list, p.per_page)
|
||||||
|
return paginator.get_elided_page_range(number=number,
|
||||||
|
on_each_side=on_each_side,
|
||||||
|
on_ends=on_ends)
|
||||||
|
|
||||||
|
@register.filter
|
||||||
|
def get_item(dictionary, key):
|
||||||
|
return dictionary.get(key)
|
||||||
3
apps/core/tests.py
Normal file
3
apps/core/tests.py
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
||||||
7
apps/core/urls.py
Normal file
7
apps/core/urls.py
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
from django.urls import path, include
|
||||||
|
from .views import HomeView
|
||||||
|
app_name = "core"
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('', HomeView.as_view(), name='home'),
|
||||||
|
]
|
||||||
0
apps/core/utils/__init__.py
Normal file
0
apps/core/utils/__init__.py
Normal file
51
apps/core/utils/jalali_date.py
Normal file
51
apps/core/utils/jalali_date.py
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
from django import forms
|
||||||
|
from django.conf import settings
|
||||||
|
from django.templatetags.static import static
|
||||||
|
from django.contrib.admin.widgets import AdminDateWidget
|
||||||
|
from django.forms.fields import DateField, SplitDateTimeField, TimeField, DateTimeField
|
||||||
|
from django.utils.encoding import force_str
|
||||||
|
from datetime import date as datetime_date, datetime as datetime_datetime
|
||||||
|
from jdatetime import GregorianToJalali, datetime as jalali_datetime
|
||||||
|
import jdatetime
|
||||||
|
|
||||||
|
class JalaliDateField(DateField):
|
||||||
|
def __init__(self, *, input_formats=None, **kwargs):
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
self.input_formats.insert(0, settings.JALALI_DATE_DEFAULTS['Strftime']['date'])
|
||||||
|
|
||||||
|
def prepare_value(self, value):
|
||||||
|
if isinstance(value, datetime_date):
|
||||||
|
date_obj = jdatetime.datetime.fromgregorian(datetime=value)
|
||||||
|
return date_obj.strftime(settings.JALALI_DATE_DEFAULTS['Strftime']['date'])
|
||||||
|
|
||||||
|
return value
|
||||||
|
|
||||||
|
def strptime(self, value, format):
|
||||||
|
return jalali_datetime.strptime(force_str(value), format).togregorian().date()
|
||||||
|
|
||||||
|
|
||||||
|
class CustomSelectWidget(forms.widgets.Select):
|
||||||
|
option_template_name = 'widgets/select_option.html'
|
||||||
|
|
||||||
|
|
||||||
|
class AdminJalaliDateWidget(AdminDateWidget):
|
||||||
|
template_name = "jalali_date/widgets/date.html"
|
||||||
|
|
||||||
|
# @property
|
||||||
|
# def media(self):
|
||||||
|
# js = settings.JALALI_DATE_DEFAULTS['Static']['js']
|
||||||
|
# css = settings.JALALI_DATE_DEFAULTS['Static']['css']
|
||||||
|
# return forms.Media(js=[static(path) for path in js], css=css)
|
||||||
|
|
||||||
|
def __init__(self, attrs=None, format=None):
|
||||||
|
final_attrs = {'class': 'jalali_date-date', 'size': '10'}
|
||||||
|
if attrs is not None:
|
||||||
|
final_attrs.update(attrs)
|
||||||
|
super(AdminJalaliDateWidget, self).__init__(attrs=final_attrs, format=format)
|
||||||
|
|
||||||
|
def render(self, name, value, attrs=None, renderer=None):
|
||||||
|
"""Render the widget as an HTML string."""
|
||||||
|
context = self.get_context(name, value, attrs)
|
||||||
|
return self._render(self.template_name, context, renderer)
|
||||||
|
|
||||||
|
|
||||||
10
apps/core/views.py
Normal file
10
apps/core/views.py
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
from django.contrib.auth.decorators import login_required
|
||||||
|
from django.shortcuts import render
|
||||||
|
from django.utils.decorators import method_decorator
|
||||||
|
from django.views.generic import TemplateView
|
||||||
|
|
||||||
|
# Create your views here.
|
||||||
|
# @method_decorator(login_required, name='dispatch')
|
||||||
|
class HomeView(TemplateView):
|
||||||
|
template_name = 'core/home.html'
|
||||||
|
|
||||||
|
|
@ -37,9 +37,6 @@
|
||||||
</button>
|
</button>
|
||||||
<div class="collapse navbar-collapse" id="navbarNav">
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav">
|
||||||
<li class="nav-item active">
|
|
||||||
<a class="nav-link" href="{% url 'superapp:app_list' %}">home <span class="sr-only"></span></a>
|
|
||||||
</li>
|
|
||||||
{% if request.user.is_authenticated %}
|
{% if request.user.is_authenticated %}
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="{% url 'users:logout' %}">({{ request.user.phone_number }}) Logout</a>
|
<a class="nav-link" href="{% url 'users:logout' %}">({{ request.user.phone_number }}) Logout</a>
|
||||||
|
|
|
||||||
12
templates/core/home.html
Normal file
12
templates/core/home.html
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% load static %}
|
||||||
|
{% load crispy_forms_tags %}
|
||||||
|
{% load jalali_tags %}
|
||||||
|
|
||||||
|
{% block title %}Accounts: Home{% endblock %}
|
||||||
|
{% block page_title %}Accounts: Home{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
wallet
|
||||||
|
{% endblock %}
|
||||||
Loading…
Add table
Reference in a new issue