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