Show More
@@ -1,12 +1,14 b'' | |||||
1 | from django.contrib import admin |
|
1 | from django.contrib import admin | |
2 | from boards.models import Post, Tag, User, Ban |
|
2 | from boards.models import Post, Tag, User, Ban | |
3 |
|
3 | |||
|
4 | ||||
4 | class PostAdmin(admin.ModelAdmin): |
|
5 | class PostAdmin(admin.ModelAdmin): | |
5 |
|
6 | |||
6 | list_display = ('id', 'title', 'text') |
|
7 | list_display = ('id', 'title', 'text') | |
7 | list_filter = ('pub_time', 'tags') |
|
8 | list_filter = ('pub_time', 'tags') | |
8 | search_fields = ('id', 'title', 'text') |
|
9 | search_fields = ('id', 'title', 'text') | |
9 |
|
10 | |||
|
11 | ||||
10 | class TagAdmin(admin.ModelAdmin): |
|
12 | class TagAdmin(admin.ModelAdmin): | |
11 |
|
13 | |||
12 | list_display = ('name', 'linked') |
|
14 | list_display = ('name', 'linked') |
@@ -7,15 +7,11 b' import time' | |||||
7 | from boards.models import TITLE_MAX_LENGTH, User |
|
7 | from boards.models import TITLE_MAX_LENGTH, User | |
8 | from neboard import settings |
|
8 | from neboard import settings | |
9 | from boards import utils |
|
9 | from boards import utils | |
|
10 | import boards.settings as board_settings | |||
10 |
|
11 | |||
11 | LAST_POST_TIME = "last_post_time" |
|
12 | LAST_POST_TIME = "last_post_time" | |
12 | LAST_LOGIN_TIME = "last_login_time" |
|
13 | LAST_LOGIN_TIME = "last_login_time" | |
13 |
|
14 | |||
14 | LOGIN_DELAY = 60 * 60 |
|
|||
15 |
|
||||
16 | MAX_TEXT_LENGTH = 30000 |
|
|||
17 | MAX_IMAGE_SIZE = 8 * 1024 * 1024 |
|
|||
18 |
|
||||
19 |
|
15 | |||
20 | class PlainErrorList(ErrorList): |
|
16 | class PlainErrorList(ErrorList): | |
21 | def __unicode__(self): |
|
17 | def __unicode__(self): | |
@@ -73,18 +69,20 b' class PostForm(NeboardForm):' | |||||
73 | def clean_text(self): |
|
69 | def clean_text(self): | |
74 | text = self.cleaned_data['text'] |
|
70 | text = self.cleaned_data['text'] | |
75 | if text: |
|
71 | if text: | |
76 | if len(text) > MAX_TEXT_LENGTH: |
|
72 | if len(text) > board_settings.MAX_TEXT_LENGTH: | |
77 | raise forms.ValidationError(_('Text must have less than %s ' |
|
73 | raise forms.ValidationError(_('Text must have less than %s ' | |
78 | 'characters') % |
|
74 | 'characters') % | |
79 |
str( |
|
75 | str(board_settings | |
|
76 | .MAX_TEXT_LENGTH)) | |||
80 | return text |
|
77 | return text | |
81 |
|
78 | |||
82 | def clean_image(self): |
|
79 | def clean_image(self): | |
83 | image = self.cleaned_data['image'] |
|
80 | image = self.cleaned_data['image'] | |
84 | if image: |
|
81 | if image: | |
85 | if image._size > MAX_IMAGE_SIZE: |
|
82 | if image._size > board_settings.MAX_IMAGE_SIZE: | |
86 |
raise forms.ValidationError( |
|
83 | raise forms.ValidationError( | |
87 | 'bytes') % str(MAX_IMAGE_SIZE)) |
|
84 | _('Image must be less than %s bytes') | |
|
85 | % str(board_settings.MAX_IMAGE_SIZE)) | |||
88 | return image |
|
86 | return image | |
89 |
|
87 | |||
90 | def clean(self): |
|
88 | def clean(self): | |
@@ -233,9 +231,9 b' class LoginForm(NeboardForm):' | |||||
233 |
|
231 | |||
234 | current_delay = int(now - last_login_time) |
|
232 | current_delay = int(now - last_login_time) | |
235 |
|
233 | |||
236 |
if current_delay < LOGIN_ |
|
234 | if current_delay < board_settings.LOGIN_TIMEOUT: | |
237 | error_message = _('Wait %s minutes after last login') % str( |
|
235 | error_message = _('Wait %s minutes after last login') % str( | |
238 |
(LOGIN_ |
|
236 | (board_settings.LOGIN_TIMEOUT - current_delay) / 60) | |
239 | self._errors['user_id'] = self.error_class([error_message]) |
|
237 | self._errors['user_id'] = self.error_class([error_message]) | |
240 |
|
238 | |||
241 | can_post = False |
|
239 | can_post = False |
@@ -1,8 +1,8 b'' | |||||
1 | import sys |
|
1 | import sys | |
2 | import cProfile |
|
|||
3 | from cStringIO import StringIO |
|
2 | from cStringIO import StringIO | |
4 | from django.conf import settings |
|
3 | from django.conf import settings | |
5 |
import |
|
4 | import line_profiler | |
|
5 | ||||
6 |
|
6 | |||
7 | class ProfilerMiddleware(object): |
|
7 | class ProfilerMiddleware(object): | |
8 | def process_view(self, request, callback, callback_args, callback_kwargs): |
|
8 | def process_view(self, request, callback, callback_args, callback_kwargs): |
@@ -6,6 +6,7 b' from neboard import settings' | |||||
6 |
|
6 | |||
7 | __author__ = 'neko259' |
|
7 | __author__ = 'neko259' | |
8 |
|
8 | |||
|
9 | ||||
9 | # TODO Make tests for all of these |
|
10 | # TODO Make tests for all of these | |
10 | class AllThreadsFeed(Feed): |
|
11 | class AllThreadsFeed(Feed): | |
11 |
|
12 | |||
@@ -14,7 +15,7 b' class AllThreadsFeed(Feed):' | |||||
14 | description_template = 'boards/rss/post.html' |
|
15 | description_template = 'boards/rss/post.html' | |
15 |
|
16 | |||
16 | def items(self): |
|
17 | def items(self): | |
17 |
|
|
18 | return Post.objects.get_threads(order_by='-pub_time') | |
18 |
|
19 | |||
19 | def item_title(self, item): |
|
20 | def item_title(self, item): | |
20 | return item.title |
|
21 | return item.title |
@@ -1,1 +1,4 b'' | |||||
1 | CACHE_TIMEOUT = 600 # Timeout for caching, if cache is used No newline at end of file |
|
1 | CACHE_TIMEOUT = 600 # Timeout for caching, if cache is used | |
|
2 | LOGIN_TIMEOUT = 3600 # Timeout between login tries | |||
|
3 | MAX_TEXT_LENGTH = 30000 # Max post length in characters | |||
|
4 | MAX_IMAGE_SIZE = 8 * 1024 * 1024 # Max image size |
General Comments 0
You need to be logged in to leave comments.
Login now