Show More
@@ -2,7 +2,7 b' import re' | |||
|
2 | 2 | from captcha.fields import CaptchaField |
|
3 | 3 | from django import forms |
|
4 | 4 | from django.forms.util import ErrorList |
|
5 | from boards.models import TITLE_MAX_LENGTH | |
|
5 | from boards.models import TITLE_MAX_LENGTH, User | |
|
6 | 6 | from neboard import settings |
|
7 | 7 | from boards import utils |
|
8 | 8 | |
@@ -131,3 +131,21 b' class ThreadCaptchaForm(ThreadForm):' | |||
|
131 | 131 | |
|
132 | 132 | class SettingsForm(forms.Form): |
|
133 | 133 | theme = forms.ChoiceField(choices=settings.THEMES, widget=forms.RadioSelect) |
|
134 | ||
|
135 | ||
|
136 | class LoginForm(forms.Form): | |
|
137 | user_id = forms.CharField() | |
|
138 | ||
|
139 | def clean_user_id(self): | |
|
140 | user_id = self.cleaned_data['user_id'] | |
|
141 | if user_id: | |
|
142 | users = User.objects.filter(user_id=user_id) | |
|
143 | if len(users) == 0: | |
|
144 | raise forms.ValidationError('No such user found') | |
|
145 | ||
|
146 | return user_id | |
|
147 | ||
|
148 | def clean(self): | |
|
149 | cleaned_data = super(LoginForm, self).clean() | |
|
150 | ||
|
151 | return cleaned_data No newline at end of file |
|
1 | NO CONTENT: modified file, binary diff hidden |
@@ -7,7 +7,7 b' msgid ""' | |||
|
7 | 7 | msgstr "" |
|
8 | 8 | "Project-Id-Version: PACKAGE VERSION\n" |
|
9 | 9 | "Report-Msgid-Bugs-To: \n" |
|
10 |
"POT-Creation-Date: 2013-09-06 21: |
|
|
10 | "POT-Creation-Date: 2013-09-06 21:49+0300\n" | |
|
11 | 11 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
|
12 | 12 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
|
13 | 13 | "Language-Team: LANGUAGE <LL@li.org>\n" |
@@ -62,10 +62,23 b' msgstr "\xd0\x92\xd1\x81\xd0\xb5 \xd1\x82\xd0\xb5\xd0\xbc\xd1\x8b"' | |||
|
62 | 62 | msgid "Settings" |
|
63 | 63 | msgstr "ΠΠ°ΡΡΡΠΎΠΉΠΊΠΈ" |
|
64 | 64 | |
|
65 | #: templates/boards/base.html:42 templates/boards/login.html:6 | |
|
66 | #: templates/boards/login.html.py:21 | |
|
67 | msgid "Login" | |
|
68 | msgstr "ΠΡ ΠΎΠ΄" | |
|
69 | ||
|
65 | 70 | #: templates/boards/base.html:43 |
|
66 | 71 | msgid "Up" |
|
67 | 72 | msgstr "ΠΠ²Π΅ΡΡ " |
|
68 | 73 | |
|
74 | #: templates/boards/login.html:15 | |
|
75 | msgid "User ID" | |
|
76 | msgstr "ID ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ" | |
|
77 | ||
|
78 | #: templates/boards/login.html:24 | |
|
79 | msgid "Insert your user id above" | |
|
80 | msgstr "ΠΡΡΠ°Π²ΡΡΠ΅ ΡΠ²ΠΎΠΉ ID ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ Π²ΡΡΠ΅" | |
|
81 | ||
|
69 | 82 | #: templates/boards/posting_general.html:18 |
|
70 | 83 | msgid "Tag: " |
|
71 | 84 | msgstr "Π’Π΅Π³: " |
@@ -285,8 +285,9 b' class User(models.Model):' | |||
|
285 | 285 | registration_time = models.DateTimeField() |
|
286 | 286 | last_access_time = models.DateTimeField() |
|
287 | 287 | |
|
288 | fav_tags = models.ManyToManyField(Tag) | |
|
289 |
fav_threads = models.ManyToManyField(Post, related_name='+' |
|
|
288 | fav_tags = models.ManyToManyField(Tag, null=True, blank=True) | |
|
289 | fav_threads = models.ManyToManyField(Post, related_name='+', null=True, | |
|
290 | blank=True) | |
|
290 | 291 | |
|
291 | 292 | def save_setting(self, name, value): |
|
292 | 293 | setting, created = Setting.objects.get_or_create(name=name, user=self) |
@@ -322,6 +323,7 b' class Setting(models.Model):' | |||
|
322 | 323 | value = models.CharField(max_length=50) |
|
323 | 324 | user = models.ForeignKey(User) |
|
324 | 325 | |
|
326 | ||
|
325 | 327 | class Ban(models.Model): |
|
326 | 328 | ip = models.GenericIPAddressField() |
|
327 | 329 |
@@ -128,7 +128,7 b' p {' | |||
|
128 | 128 | .form-errors { |
|
129 | 129 | padding-left: 1ex; |
|
130 | 130 | font-weight: bold; |
|
131 |
vertical-align: |
|
|
131 | vertical-align: middle; | |
|
132 | 132 | } |
|
133 | 133 | |
|
134 | 134 | .post-form input, .post-form textarea { |
@@ -39,7 +39,7 b'' | |||
|
39 | 39 | |
|
40 | 40 | <div class="navigation_panel"> |
|
41 | 41 | {% block metapanel %}{% endblock %} |
|
42 | [<a href="rss/">RSS</a>] | |
|
42 | [<a href="{% url "login" %}">{% trans 'Login' %}</a>] | |
|
43 | 43 | <a class="link" href="#top">{% trans 'Up' %}</a> |
|
44 | 44 | </div> |
|
45 | 45 |
@@ -1,22 +1,29 b'' | |||
|
1 | <!DOCTYPE html> | |
|
2 | <html> | |
|
3 | <head> | |
|
4 | <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/md/login.css" media="all"/> | |
|
5 | <title>Login page</title> | |
|
6 | </head> | |
|
1 | {% extends "boards/base.html" %} | |
|
2 | ||
|
3 | {% load i18n %} | |
|
4 | ||
|
5 | {% block head %} | |
|
6 | <title>{% trans 'Login' %}</title> | |
|
7 | {% endblock %} | |
|
8 | ||
|
9 | {% block content %} | |
|
7 | 10 | |
|
8 | <body> | |
|
9 | {% if error != none%} | |
|
10 | <span id="error_message"> | |
|
11 | {{ error }} | |
|
12 | </span> | |
|
13 | {% endif %} | |
|
11 | <form enctype="multipart/form-data" method="post"> | |
|
12 | <div class="post-form-w"> | |
|
13 | <div class="post-form"> | |
|
14 | <div class="form-row"> | |
|
15 | <div class="form-label">{% trans 'User ID' %}</div> | |
|
16 | <div class="form-input">{{ form.user_id }}</div> | |
|
17 | <div class="form-errors">{{ form.user_id.errors }}</div> | |
|
18 | </div> | |
|
19 | </div> | |
|
20 | <div class="form-submit"> | |
|
21 | <input type="submit" value="{% trans "Login" %}"/> | |
|
22 | </div> | |
|
23 | <div> | |
|
24 | {% trans 'Insert your user id above' %} | |
|
25 | </div> | |
|
26 | </div> | |
|
27 | </form> | |
|
14 | 28 | |
|
15 | <form action="login" method="POST">{% csrf_token %} | |
|
16 | ||
|
17 | Login: <input type="text" name="name"><br /> | |
|
18 | Password: <input type="password" name="password"><br /> | |
|
19 | <input type="submit"> | |
|
20 | </form> | |
|
21 | </body> | |
|
22 | </html> No newline at end of file | |
|
29 | {% endblock %} No newline at end of file |
@@ -171,6 +171,7 b'' | |||
|
171 | 171 | {% endif %} |
|
172 | 172 | ">{{ page }}</a>] |
|
173 | 173 | {% endfor %} |
|
174 | [<a href="rss/">RSS</a>] | |
|
174 | 175 | </span> |
|
175 | 176 | |
|
176 | 177 | {% endblock %} |
@@ -113,6 +113,7 b'' | |||
|
113 | 113 | {{ posts.0.get_reply_count }} {% trans 'replies' %}, |
|
114 | 114 | {{ posts.0.get_images_count }} {% trans 'images' %}. |
|
115 | 115 | {% trans 'Last update: ' %}{{ posts.0.last_edit_time }} |
|
116 | [<a href="rss/">RSS</a>] | |
|
116 | 117 | </span> |
|
117 | 118 | |
|
118 | 119 | {% endblock %} |
@@ -14,9 +14,7 b" urlpatterns = patterns(''," | |||
|
14 | 14 | url(r'^page/(?P<page>\w+)/$', views.index, name='index'), |
|
15 | 15 | |
|
16 | 16 | # login page |
|
17 | url(r'^login$', views.login, name='login'), | |
|
18 | # logout page | |
|
19 | url(r'^logout$', views.logout, name='logout'), | |
|
17 | url(r'^login/$', views.login, name='login'), | |
|
20 | 18 | |
|
21 | 19 | # /boards/tag/tag_name/ |
|
22 | 20 | url(r'^tag/(?P<tag_name>\w+)/$', views.tag, name='tag'), |
@@ -25,8 +23,8 b" urlpatterns = patterns(''," | |||
|
25 | 23 | # /boards/thread/ |
|
26 | 24 | url(r'^thread/(?P<post_id>\w+)/$', views.thread, name='thread'), |
|
27 | 25 | # /boards/theme/theme_name/ |
|
28 | url(r'^settings$', views.settings, name='settings'), | |
|
29 | url(r'^tags$', views.all_tags, name='tags'), | |
|
26 | url(r'^settings/$', views.settings, name='settings'), | |
|
27 | url(r'^tags/$', views.all_tags, name='tags'), | |
|
30 | 28 | url(r'^captcha/', include('captcha.urls')), |
|
31 | 29 | url(r'^jump/(?P<post_id>\w+)/$', views.jump_to_post, name='jumper'), |
|
32 | 30 | url(r'^authors/$', views.authors, name='authors'), |
@@ -9,7 +9,7 b' from boards import forms' | |||
|
9 | 9 | import boards |
|
10 | 10 | from boards import utils |
|
11 | 11 | from boards.forms import ThreadForm, PostForm, SettingsForm, PlainErrorList, \ |
|
12 | ThreadCaptchaForm, PostCaptchaForm | |
|
12 | ThreadCaptchaForm, PostCaptchaForm, LoginForm | |
|
13 | 13 | |
|
14 | 14 | from boards.models import Post, Tag, Ban, User, RANK_USER, RANK_MODERATOR, NO_PARENT |
|
15 | 15 | from boards import authors |
@@ -150,31 +150,23 b' def thread(request, post_id):' | |||
|
150 | 150 | |
|
151 | 151 | |
|
152 | 152 | def login(request): |
|
153 |
"""Log in |
|
|
154 | ||
|
155 | if 'name' in request.POST and 'password' in request.POST: | |
|
156 | request.session['admin'] = False | |
|
153 | """Log in with user id""" | |
|
157 | 154 | |
|
158 | isAdmin = len(Admin.objects.filter(name=request.POST['name'], | |
|
159 | password=request.POST[ | |
|
160 | 'password'])) > 0 | |
|
161 | ||
|
162 | if isAdmin: | |
|
163 | request.session['admin'] = True | |
|
155 | context = _init_default_context(request) | |
|
164 | 156 | |
|
165 | response = HttpResponseRedirect('/') | |
|
166 | ||
|
167 | else: | |
|
168 | response = render(request, 'boards/login.html', {'error': 'Login error'}) | |
|
169 | else: | |
|
170 | response = render(request, 'boards/login.html', {}) | |
|
157 | if request.method == 'POST': | |
|
158 | form = LoginForm(request.POST, request.FILES, error_class=PlainErrorList) | |
|
159 | if form.is_valid(): | |
|
160 | user = User.objects.get(user_id=form.cleaned_data['user_id']) | |
|
161 | request.session['user_id'] = user.id | |
|
162 | return redirect(index) | |
|
171 | 163 | |
|
172 | return response | |
|
173 | ||
|
164 | else: | |
|
165 | form = LoginForm() | |
|
174 | 166 | |
|
175 | def logout(request): | |
|
176 | request.session['admin'] = False | |
|
177 | return HttpResponseRedirect('/') | |
|
167 | context['form'] = form | |
|
168 | ||
|
169 | return render(request, 'boards/login.html', context) | |
|
178 | 170 | |
|
179 | 171 | |
|
180 | 172 | def settings(request): |
General Comments 0
You need to be logged in to leave comments.
Login now