Добавлена авторизация
This commit is contained in:
@@ -12,6 +12,7 @@ from django.db.models import Count, Sum
|
|||||||
from asuzr.common import custom_date
|
from asuzr.common import custom_date
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
|
||||||
|
@login_required
|
||||||
def prod_list(request):
|
def prod_list(request):
|
||||||
product_list = Product.objects.all()
|
product_list = Product.objects.all()
|
||||||
t = loader.get_template('asuzr/prod_list.html')
|
t = loader.get_template('asuzr/prod_list.html')
|
||||||
@@ -20,10 +21,10 @@ def prod_list(request):
|
|||||||
})
|
})
|
||||||
return HttpResponse(t.render(c))
|
return HttpResponse(t.render(c))
|
||||||
|
|
||||||
|
@login_required
|
||||||
def prod_detail(request, prod_id):
|
def prod_detail(request, prod_id):
|
||||||
return HttpResponse("This is %s" % prod_id)
|
return HttpResponse("This is %s" % prod_id)
|
||||||
|
|
||||||
|
|
||||||
def get_filtered_list(p_list, year, month):
|
def get_filtered_list(p_list, year, month):
|
||||||
filtered_list=[]
|
filtered_list=[]
|
||||||
for a in p_list:
|
for a in p_list:
|
||||||
@@ -37,7 +38,7 @@ def get_orders_by_date(dt):
|
|||||||
order_list = Order.objects.filter(date=dt).order_by('id')
|
order_list = Order.objects.filter(date=dt).order_by('id')
|
||||||
return order_list
|
return order_list
|
||||||
|
|
||||||
|
@login_required
|
||||||
def main(request, day, month, year):
|
def main(request, day, month, year):
|
||||||
d,m,y=int(day),int(month), int(year)
|
d,m,y=int(day),int(month), int(year)
|
||||||
|
|
||||||
@@ -119,6 +120,7 @@ def orders (request, archive):
|
|||||||
})
|
})
|
||||||
return HttpResponse(t.render(c))
|
return HttpResponse(t.render(c))
|
||||||
|
|
||||||
|
@login_required
|
||||||
def desreport(request):
|
def desreport(request):
|
||||||
start_date = request.GET.get('sdate', date.today().strftime('%d.%m.%y'))
|
start_date = request.GET.get('sdate', date.today().strftime('%d.%m.%y'))
|
||||||
sdate = datetime.strptime(start_date, '%d.%m.%y')
|
sdate = datetime.strptime(start_date, '%d.%m.%y')
|
||||||
@@ -133,6 +135,7 @@ def desreport(request):
|
|||||||
})
|
})
|
||||||
return HttpResponse(t.render(c))
|
return HttpResponse(t.render(c))
|
||||||
|
|
||||||
|
@login_required
|
||||||
def production_table(request, order_id):
|
def production_table(request, order_id):
|
||||||
order_list = Order.objects.filter(is_done=False).order_by('-id')
|
order_list = Order.objects.filter(is_done=False).order_by('-id')
|
||||||
sel_order = Order.objects.filter(id=order_id)
|
sel_order = Order.objects.filter(id=order_id)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from django.conf.urls import patterns, include, url
|
from django.conf.urls import patterns, include, url
|
||||||
|
from django.contrib.auth.views import login, logout
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
admin.autodiscover()
|
admin.autodiscover()
|
||||||
@@ -15,4 +16,6 @@ urlpatterns = patterns('',
|
|||||||
url(r'^production_table/(?P<order_id>\d+)/$', 'asuzr.views.production_table'),
|
url(r'^production_table/(?P<order_id>\d+)/$', 'asuzr.views.production_table'),
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
url(r'^inplaceeditform/', include('inplaceeditform.urls')),
|
url(r'^inplaceeditform/', include('inplaceeditform.urls')),
|
||||||
|
url(r'^accounts/login/$', login),
|
||||||
|
url(r'^accounts/logout/$', logout),
|
||||||
)
|
)
|
||||||
|
|||||||
12
templates/registration/logged_out.html
Normal file
12
templates/registration/logged_out.html
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{% extends "admin/base_site.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block breadcrumbs %}<div class="breadcrumbs"><a href="{% url 'admin:index' %}">{% trans 'Home' %}</a></div>{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<p>{% trans "Thanks for spending some quality time with the Web site today." %}</p>
|
||||||
|
|
||||||
|
<p><a href="{% url 'admin:index' %}">{% trans 'Log in again' %}</a></p>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
56
templates/registration/login.html
Normal file
56
templates/registration/login.html
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
{% extends "admin/base_site.html" %}
|
||||||
|
{% load i18n admin_static %}
|
||||||
|
|
||||||
|
{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/login.css" %}" />{% endblock %}
|
||||||
|
|
||||||
|
{% block bodyclass %}login{% endblock %}
|
||||||
|
|
||||||
|
{% block nav-global %}{% endblock %}
|
||||||
|
|
||||||
|
{% block content_title %}{% endblock %}
|
||||||
|
|
||||||
|
{% block breadcrumbs %}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% if form.errors and not form.non_field_errors and not form.this_is_the_login_form.errors %}
|
||||||
|
<p class="errornote">
|
||||||
|
{% if form.errors.items|length == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %}
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if form.non_field_errors or form.this_is_the_login_form.errors %}
|
||||||
|
{% for error in form.non_field_errors|add:form.this_is_the_login_form.errors %}
|
||||||
|
<p class="errornote">
|
||||||
|
{{ error }}
|
||||||
|
</p>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<div id="content-main">
|
||||||
|
<form action="{{ app_path }}" method="post" id="login-form">{% csrf_token %}
|
||||||
|
<div class="form-row">
|
||||||
|
{% if not form.this_is_the_login_form.errors %}{{ form.username.errors }}{% endif %}
|
||||||
|
<label for="id_username" class="required">{{ form.username.label }}:</label> {{ form.username }}
|
||||||
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
{% if not form.this_is_the_login_form.errors %}{{ form.password.errors }}{% endif %}
|
||||||
|
<label for="id_password" class="required">{% trans 'Password:' %}</label> {{ form.password }}
|
||||||
|
<input type="hidden" name="this_is_the_login_form" value="1" />
|
||||||
|
<input type="hidden" name="next" value="{{ next }}" />
|
||||||
|
</div>
|
||||||
|
{% url 'admin_password_reset' as password_reset_url %}
|
||||||
|
{% if password_reset_url %}
|
||||||
|
<div class="password-reset-link">
|
||||||
|
<a href="{{ password_reset_url }}">{% trans 'Forgotten your password or username?' %}</a>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="submit-row">
|
||||||
|
<label> </label><input type="submit" value="{% trans 'Log in' %}" />
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
document.getElementById('id_username').focus()
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
19
templates/registration/password_change_done.html
Normal file
19
templates/registration/password_change_done.html
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
{% extends "admin/base_site.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
{% block userlinks %}{% url 'django-admindocs-docroot' as docsroot %}{% if docsroot %}<a href="{{ docsroot }}">{% trans 'Documentation' %}</a> / {% endif %}{% trans 'Change password' %} / <a href="{% url 'admin:logout' %}">{% trans 'Log out' %}</a>{% endblock %}
|
||||||
|
{% block breadcrumbs %}
|
||||||
|
<div class="breadcrumbs">
|
||||||
|
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
|
||||||
|
› {% trans 'Password change' %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block title %}{% trans 'Password change successful' %}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h1>{% trans 'Password change successful' %}</h1>
|
||||||
|
|
||||||
|
<p>{% trans 'Your password was changed.' %}</p>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
55
templates/registration/password_change_form.html
Normal file
55
templates/registration/password_change_form.html
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
{% extends "admin/base_site.html" %}
|
||||||
|
{% load i18n static %}
|
||||||
|
{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}" />{% endblock %}
|
||||||
|
{% block userlinks %}{% url 'django-admindocs-docroot' as docsroot %}{% if docsroot %}<a href="{{ docsroot }}">{% trans 'Documentation' %}</a> / {% endif %} {% trans 'Change password' %} / <a href="{% url 'admin:logout' %}">{% trans 'Log out' %}</a>{% endblock %}
|
||||||
|
{% block breadcrumbs %}
|
||||||
|
<div class="breadcrumbs">
|
||||||
|
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
|
||||||
|
› {% trans 'Password change' %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block title %}{% trans 'Password change' %}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}<div id="content-main">
|
||||||
|
|
||||||
|
<form action="" method="post">{% csrf_token %}
|
||||||
|
<div>
|
||||||
|
{% if form.errors %}
|
||||||
|
<p class="errornote">
|
||||||
|
{% if form.errors.items|length == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %}
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<h1>{% trans 'Password change' %}</h1>
|
||||||
|
|
||||||
|
<p>{% trans "Please enter your old password, for security's sake, and then enter your new password twice so we can verify you typed it in correctly." %}</p>
|
||||||
|
|
||||||
|
<fieldset class="module aligned wide">
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
{{ form.old_password.errors }}
|
||||||
|
<label for="id_old_password" class="required">{% trans 'Old password' %}:</label>{{ form.old_password }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
{{ form.new_password1.errors }}
|
||||||
|
<label for="id_new_password1" class="required">{% trans 'New password' %}:</label>{{ form.new_password1 }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
{{ form.new_password2.errors }}
|
||||||
|
<label for="id_new_password2" class="required">{% trans 'Password (again)' %}:</label>{{ form.new_password2 }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<div class="submit-row">
|
||||||
|
<input type="submit" value="{% trans 'Change my password' %}" class="default" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">document.getElementById("id_old_password").focus();</script>
|
||||||
|
</div>
|
||||||
|
</form></div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
21
templates/registration/password_reset_complete.html
Normal file
21
templates/registration/password_reset_complete.html
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{% extends "admin/base_site.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block breadcrumbs %}
|
||||||
|
<div class="breadcrumbs">
|
||||||
|
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
|
||||||
|
› {% trans 'Password reset' %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block title %}{% trans 'Password reset complete' %}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h1>{% trans 'Password reset complete' %}</h1>
|
||||||
|
|
||||||
|
<p>{% trans "Your password has been set. You may go ahead and log in now." %}</p>
|
||||||
|
|
||||||
|
<p><a href="{{ login_url }}">{% trans 'Log in' %}</a></p>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
37
templates/registration/password_reset_confirm.html
Normal file
37
templates/registration/password_reset_confirm.html
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
{% extends "admin/base_site.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block breadcrumbs %}
|
||||||
|
<div class="breadcrumbs">
|
||||||
|
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
|
||||||
|
› {% trans 'Password reset confirmation' %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block title %}{% trans 'Password reset' %}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{% if validlink %}
|
||||||
|
|
||||||
|
<h1>{% trans 'Enter new password' %}</h1>
|
||||||
|
|
||||||
|
<p>{% trans "Please enter your new password twice so we can verify you typed it in correctly." %}</p>
|
||||||
|
|
||||||
|
<form action="" method="post">{% csrf_token %}
|
||||||
|
{{ form.new_password1.errors }}
|
||||||
|
<p class="aligned wide"><label for="id_new_password1">{% trans 'New password:' %}</label>{{ form.new_password1 }}</p>
|
||||||
|
{{ form.new_password2.errors }}
|
||||||
|
<p class="aligned wide"><label for="id_new_password2">{% trans 'Confirm password:' %}</label>{{ form.new_password2 }}</p>
|
||||||
|
<p><input type="submit" value="{% trans 'Change my password' %}" /></p>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
<h1>{% trans 'Password reset unsuccessful' %}</h1>
|
||||||
|
|
||||||
|
<p>{% trans "The password reset link was invalid, possibly because it has already been used. Please request a new password reset." %}</p>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
21
templates/registration/password_reset_done.html
Normal file
21
templates/registration/password_reset_done.html
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{% extends "admin/base_site.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block breadcrumbs %}
|
||||||
|
<div class="breadcrumbs">
|
||||||
|
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
|
||||||
|
› {% trans 'Password reset' %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block title %}{% trans 'Password reset successful' %}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h1>{% trans 'Password reset successful' %}</h1>
|
||||||
|
|
||||||
|
<p>{% trans "We've emailed you instructions for setting your password. You should be receiving them shortly." %}</p>
|
||||||
|
|
||||||
|
<p>{% trans "If you don't receive an email, please make sure you've entered the address you registered with, and check your spam folder." %}</p>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
14
templates/registration/password_reset_email.html
Normal file
14
templates/registration/password_reset_email.html
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{% load i18n %}{% autoescape off %}
|
||||||
|
{% blocktrans %}You're receiving this email because you requested a password reset for your user account at {{ site_name }}.{% endblocktrans %}
|
||||||
|
|
||||||
|
{% trans "Please go to the following page and choose a new password:" %}
|
||||||
|
{% block reset_link %}
|
||||||
|
{{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %}
|
||||||
|
{% endblock %}
|
||||||
|
{% trans "Your username, in case you've forgotten:" %} {{ user.get_username }}
|
||||||
|
|
||||||
|
{% trans "Thanks for using our site!" %}
|
||||||
|
|
||||||
|
{% blocktrans %}The {{ site_name }} team{% endblocktrans %}
|
||||||
|
|
||||||
|
{% endautoescape %}
|
||||||
24
templates/registration/password_reset_form.html
Normal file
24
templates/registration/password_reset_form.html
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{% extends "admin/base_site.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block breadcrumbs %}
|
||||||
|
<div class="breadcrumbs">
|
||||||
|
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
|
||||||
|
› {% trans 'Password reset' %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block title %}{% trans "Password reset" %}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h1>{% trans "Password reset" %}</h1>
|
||||||
|
|
||||||
|
<p>{% trans "Forgotten your password? Enter your email address below, and we'll email instructions for setting a new one." %}</p>
|
||||||
|
|
||||||
|
<form action="" method="post">{% csrf_token %}
|
||||||
|
{{ form.email.errors }}
|
||||||
|
<p><label for="id_email">{% trans 'Email address:' %}</label> {{ form.email }} <input type="submit" value="{% trans 'Reset my password' %}" /></p>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user