Show More
@@ -0,0 +1,64 b'' | |||||
|
1 | # -*- coding: utf-8 -*- | |||
|
2 | import datetime | |||
|
3 | from south.db import db | |||
|
4 | from south.v2 import SchemaMigration | |||
|
5 | from django.db import models | |||
|
6 | ||||
|
7 | ||||
|
8 | class Migration(SchemaMigration): | |||
|
9 | ||||
|
10 | def forwards(self, orm): | |||
|
11 | # Adding model 'Ban' | |||
|
12 | db.create_table(u'boards_ban', ( | |||
|
13 | (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), | |||
|
14 | ('ip', self.gf('django.db.models.fields.GenericIPAddressField')(max_length=39)), | |||
|
15 | )) | |||
|
16 | db.send_create_signal(u'boards', ['Ban']) | |||
|
17 | ||||
|
18 | ||||
|
19 | # Changing field 'Post.poster_ip' | |||
|
20 | db.alter_column(u'boards_post', 'poster_ip', self.gf('django.db.models.fields.GenericIPAddressField')(max_length=39)) | |||
|
21 | ||||
|
22 | def backwards(self, orm): | |||
|
23 | # Deleting model 'Ban' | |||
|
24 | db.delete_table(u'boards_ban') | |||
|
25 | ||||
|
26 | ||||
|
27 | # Changing field 'Post.poster_ip' | |||
|
28 | db.alter_column(u'boards_post', 'poster_ip', self.gf('django.db.models.fields.IPAddressField')(max_length=15)) | |||
|
29 | ||||
|
30 | models = { | |||
|
31 | u'boards.admin': { | |||
|
32 | 'Meta': {'object_name': 'Admin'}, | |||
|
33 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | |||
|
34 | 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}), | |||
|
35 | 'password': ('django.db.models.fields.CharField', [], {'max_length': '100'}) | |||
|
36 | }, | |||
|
37 | u'boards.ban': { | |||
|
38 | 'Meta': {'object_name': 'Ban'}, | |||
|
39 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | |||
|
40 | 'ip': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39'}) | |||
|
41 | }, | |||
|
42 | u'boards.post': { | |||
|
43 | 'Meta': {'object_name': 'Post'}, | |||
|
44 | '_text_rendered': ('django.db.models.fields.TextField', [], {}), | |||
|
45 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | |||
|
46 | 'image': ('boards.thumbs.ImageWithThumbsField', [], {'max_length': '100', 'blank': 'True'}), | |||
|
47 | 'last_edit_time': ('django.db.models.fields.DateTimeField', [], {}), | |||
|
48 | 'parent': ('django.db.models.fields.BigIntegerField', [], {}), | |||
|
49 | 'poster_ip': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39'}), | |||
|
50 | 'poster_user_agent': ('django.db.models.fields.TextField', [], {}), | |||
|
51 | 'pub_time': ('django.db.models.fields.DateTimeField', [], {}), | |||
|
52 | 'tags': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['boards.Tag']", 'symmetrical': 'False'}), | |||
|
53 | 'text': ('markupfield.fields.MarkupField', [], {'rendered_field': 'True'}), | |||
|
54 | 'text_markup_type': ('django.db.models.fields.CharField', [], {'default': "'markdown'", 'max_length': '30'}), | |||
|
55 | 'title': ('django.db.models.fields.CharField', [], {'max_length': '50'}) | |||
|
56 | }, | |||
|
57 | u'boards.tag': { | |||
|
58 | 'Meta': {'object_name': 'Tag'}, | |||
|
59 | u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | |||
|
60 | 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) | |||
|
61 | } | |||
|
62 | } | |||
|
63 | ||||
|
64 | complete_apps = ['boards'] No newline at end of file |
@@ -1,6 +1,7 b'' | |||||
1 | from django.contrib import admin |
|
1 | from django.contrib import admin | |
2 | from boards.models import Post, Tag, Admin |
|
2 | from boards.models import Post, Tag, Admin, Ban | |
3 |
|
3 | |||
4 | admin.site.register(Post) |
|
4 | admin.site.register(Post) | |
5 | admin.site.register(Tag) |
|
5 | admin.site.register(Tag) | |
6 | admin.site.register(Admin) |
|
6 | admin.site.register(Admin) | |
|
7 | admin.site.register(Ban) No newline at end of file |
@@ -215,7 +215,7 b' class Post(models.Model):' | |||||
215 | escape_html=False) |
|
215 | escape_html=False) | |
216 | image = thumbs.ImageWithThumbsField(upload_to=_update_image_filename, |
|
216 | image = thumbs.ImageWithThumbsField(upload_to=_update_image_filename, | |
217 | blank=True, sizes=(IMAGE_THUMB_SIZE,)) |
|
217 | blank=True, sizes=(IMAGE_THUMB_SIZE,)) | |
218 | poster_ip = models.IPAddressField() |
|
218 | poster_ip = models.GenericIPAddressField() | |
219 | poster_user_agent = models.TextField() |
|
219 | poster_user_agent = models.TextField() | |
220 | parent = models.BigIntegerField() |
|
220 | parent = models.BigIntegerField() | |
221 | tags = models.ManyToManyField(Tag) |
|
221 | tags = models.ManyToManyField(Tag) | |
@@ -287,3 +287,11 b' class Admin(models.Model):' | |||||
287 |
|
287 | |||
288 | def __unicode__(self): |
|
288 | def __unicode__(self): | |
289 | return self.name + '/' + '*' * len(self.password) |
|
289 | return self.name + '/' + '*' * len(self.password) | |
|
290 | ||||
|
291 | ||||
|
292 | class Ban(models.Model): | |||
|
293 | ||||
|
294 | ip = models.GenericIPAddressField() | |||
|
295 | ||||
|
296 | def __unicode__(self): | |||
|
297 | return self.ip |
@@ -3,28 +3,11 b'' | |||||
3 | {% load i18n %} |
|
3 | {% load i18n %} | |
4 |
|
4 | |||
5 | {% block head %} |
|
5 | {% block head %} | |
6 |
<title>{% trans " |
|
6 | <title>{% trans "Banned" %}</title> | |
7 | {% endblock %} |
|
7 | {% endblock %} | |
8 |
|
8 | |||
9 | {% block content %} |
|
9 | {% block content %} | |
10 | <div class="post"> |
|
10 | <div class="post"> | |
11 | <h2>Authors</h2> |
|
11 | {% trans 'Your IP address has been banned. Contact the administrator' %} | |
12 | {% for nick, values in authors.items %} |
|
|||
13 | <p> |
|
|||
14 | <b>{{ nick }}</b> ({{ values.name }}): |
|
|||
15 | {% for value in values.contacts %} |
|
|||
16 | <a href="mailto:{{ value }}">{{ value }}</a> |
|
|||
17 | {% endfor %} - |
|
|||
18 | {% for role in values.roles %} |
|
|||
19 | {% trans role %} |
|
|||
20 | {% endfor %} |
|
|||
21 | </p> |
|
|||
22 | {% endfor %} |
|
|||
23 | <br /> |
|
|||
24 | <p>{% trans "Distributed under the" %} |
|
|||
25 | <a href="http://www.gnu.org/licenses/gpl.html" >GNU GPLv3</a> |
|
|||
26 | {% trans "license" %}</p> |
|
|||
27 | <p><a href="https://bitbucket.org/neko259/neboard"> |
|
|||
28 | {% trans "Repository" %}</a></p> |
|
|||
29 | </div> |
|
12 | </div> | |
30 | {% endblock %} No newline at end of file |
|
13 | {% endblock %} |
@@ -26,6 +26,7 b" urlpatterns = patterns(''," | |||||
26 | url(r'^captcha/', include('captcha.urls')), |
|
26 | url(r'^captcha/', include('captcha.urls')), | |
27 | url(r'^jump/(?P<post_id>\w+)/$', views.jump_to_post, name='jumper'), |
|
27 | url(r'^jump/(?P<post_id>\w+)/$', views.jump_to_post, name='jumper'), | |
28 | url(r'^authors/$', views.authors, name='authors'), |
|
28 | url(r'^authors/$', views.authors, name='authors'), | |
|
29 | url(r'^banned/$', views.you_are_banned, name='banned'), | |||
29 |
|
30 | |||
30 | # RSS feeds |
|
31 | # RSS feeds | |
31 | url(r'^rss/$', AllThreadsFeed()), |
|
32 | url(r'^rss/$', AllThreadsFeed()), |
@@ -9,7 +9,7 b' from boards import utils' | |||||
9 | from boards.forms import ThreadForm, PostForm, SettingsForm, PlainErrorList, \ |
|
9 | from boards.forms import ThreadForm, PostForm, SettingsForm, PlainErrorList, \ | |
10 | ThreadCaptchaForm, PostCaptchaForm |
|
10 | ThreadCaptchaForm, PostCaptchaForm | |
11 |
|
11 | |||
12 | from boards.models import Post, Admin, Tag |
|
12 | from boards.models import Post, Admin, Tag, Ban | |
13 | from boards import authors |
|
13 | from boards import authors | |
14 | import neboard |
|
14 | import neboard | |
15 |
|
15 | |||
@@ -46,6 +46,12 b' def index(request, page=0):' | |||||
46 | def _new_post(request, form, thread_id=boards.models.NO_PARENT): |
|
46 | def _new_post(request, form, thread_id=boards.models.NO_PARENT): | |
47 | """Add a new post (in thread or as a reply).""" |
|
47 | """Add a new post (in thread or as a reply).""" | |
48 |
|
48 | |||
|
49 | ip = _get_client_ip(request) | |||
|
50 | is_banned = Ban.objects.filter(ip=ip).count() > 0 | |||
|
51 | ||||
|
52 | if is_banned: | |||
|
53 | return redirect(you_are_banned) | |||
|
54 | ||||
49 | data = form.cleaned_data |
|
55 | data = form.cleaned_data | |
50 |
|
56 | |||
51 | title = data['title'] |
|
57 | title = data['title'] | |
@@ -56,8 +62,6 b' def _new_post(request, form, thread_id=b' | |||||
56 | else: |
|
62 | else: | |
57 | image = None |
|
63 | image = None | |
58 |
|
64 | |||
59 | ip = _get_client_ip(request) |
|
|||
60 |
|
||||
61 | tags = [] |
|
65 | tags = [] | |
62 |
|
66 | |||
63 | new_thread = thread_id == boards.models.NO_PARENT |
|
67 | new_thread = thread_id == boards.models.NO_PARENT | |
@@ -222,6 +226,11 b' def authors(request):' | |||||
222 | return render(request, 'boards/authors.html', context) |
|
226 | return render(request, 'boards/authors.html', context) | |
223 |
|
227 | |||
224 |
|
228 | |||
|
229 | def you_are_banned(request): | |||
|
230 | context = _init_default_context(request) | |||
|
231 | return render(request, 'boards/banned.html', context) | |||
|
232 | ||||
|
233 | ||||
225 | def _get_theme(request): |
|
234 | def _get_theme(request): | |
226 | """Get user's CSS theme""" |
|
235 | """Get user's CSS theme""" | |
227 |
|
236 |
General Comments 0
You need to be logged in to leave comments.
Login now