##// END OF EJS Templates
Allow to edit tag and post in the admin site
neko259 -
r1367:2712a5bd default
parent child Browse files
Show More
@@ -0,0 +1,19 b''
1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
3
4 from django.db import migrations, models
5
6
7 class Migration(migrations.Migration):
8
9 dependencies = [
10 ('boards', '0031_post_hidden'),
11 ]
12
13 operations = [
14 migrations.AlterField(
15 model_name='post',
16 name='tripcode',
17 field=models.CharField(default='', blank=True, max_length=50),
18 ),
19 ]
@@ -0,0 +1,19 b''
1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
3
4 from django.db import migrations, models
5
6
7 class Migration(migrations.Migration):
8
9 dependencies = [
10 ('boards', '0032_auto_20151014_2222'),
11 ]
12
13 operations = [
14 migrations.AlterField(
15 model_name='tag',
16 name='parent',
17 field=models.ForeignKey(blank=True, related_name='children', to='boards.Tag', null=True),
18 ),
19 ]
@@ -42,6 +42,8 b' TAG_MAX_LENGTH = 20'
42
42
43 TEXTAREA_ROWS = 4
43 TEXTAREA_ROWS = 4
44
44
45 TRIPCODE_DELIM = '#'
46
45
47
46 def get_timezones():
48 def get_timezones():
47 timezones = []
49 timezones = []
@@ -239,14 +241,17 b' class PostForm(NeboardForm):'
239
241
240 def get_tripcode(self):
242 def get_tripcode(self):
241 title = self.cleaned_data['title']
243 title = self.cleaned_data['title']
242 if title is not None and '#' in title:
244 if title is not None and TRIPCODE_DELIM in title:
243 code = title.split('#', maxsplit=1)[1] + neboard.settings.SECRET_KEY
245 code = title.split(TRIPCODE_DELIM, maxsplit=1)[1] + neboard.settings.SECRET_KEY
244 return hashlib.md5(code.encode()).hexdigest()
246 tripcode = hashlib.md5(code.encode()).hexdigest()
247 else:
248 tripcode = ''
249 return tripcode
245
250
246 def get_title(self):
251 def get_title(self):
247 title = self.cleaned_data['title']
252 title = self.cleaned_data['title']
248 if title is not None and '#' in title:
253 if title is not None and TRIPCODE_DELIM in title:
249 return title.split('#', maxsplit=1)[0]
254 return title.split(TRIPCODE_DELIM, maxsplit=1)[0]
250 else:
255 else:
251 return title
256 return title
252
257
@@ -97,7 +97,7 b' class Post(models.Model, Viewable):'
97 url = models.TextField()
97 url = models.TextField()
98 uid = models.TextField(db_index=True)
98 uid = models.TextField(db_index=True)
99
99
100 tripcode = models.CharField(max_length=50, null=True)
100 tripcode = models.CharField(max_length=50, blank=True, default='')
101 opening = models.BooleanField()
101 opening = models.BooleanField()
102 hidden = models.BooleanField(default=False)
102 hidden = models.BooleanField(default=False)
103
103
@@ -30,7 +30,8 b" NO_IP = '0.0.0.0'"
30 class PostManager(models.Manager):
30 class PostManager(models.Manager):
31 @transaction.atomic
31 @transaction.atomic
32 def create_post(self, title: str, text: str, file=None, thread=None,
32 def create_post(self, title: str, text: str, file=None, thread=None,
33 ip=NO_IP, tags: list=None, opening_posts: list=None, tripcode=None):
33 ip=NO_IP, tags: list=None, opening_posts: list=None,
34 tripcode=''):
34 """
35 """
35 Creates new post
36 Creates new post
36 """
37 """
@@ -48,7 +48,8 b' class Tag(models.Model, Viewable):'
48 required = models.BooleanField(default=False, db_index=True)
48 required = models.BooleanField(default=False, db_index=True)
49 description = models.TextField(blank=True)
49 description = models.TextField(blank=True)
50
50
51 parent = models.ForeignKey('Tag', null=True, related_name='children')
51 parent = models.ForeignKey('Tag', null=True, blank=True,
52 related_name='children')
52
53
53 def __str__(self):
54 def __str__(self):
54 return self.name
55 return self.name
General Comments 0
You need to be logged in to leave comments. Login now