Show More
@@ -95,14 +95,14 b' class PostManager(models.Manager):' | |||||
95 |
|
95 | |||
96 | logger = logging.getLogger('boards.post.create') |
|
96 | logger = logging.getLogger('boards.post.create') | |
97 |
|
97 | |||
98 |
logger.info('Created post # |
|
98 | logger.info('Created post #{} with title "{}" by {}'.format( | |
99 | post.title)) |
|
99 | post.id, post.title, post.poster_ip)) | |
100 |
|
100 | |||
101 | if image: |
|
101 | if image: | |
102 | post_image = PostImage.objects.create(image=image) |
|
102 | post_image = PostImage.objects.create(image=image) | |
103 | post.images.add(post_image) |
|
103 | post.images.add(post_image) | |
104 |
logger.info('Created image # |
|
104 | logger.info('Created image #{} for post #{}'.format( | |
105 | post.id)) |
|
105 | post_image.id, post.id)) | |
106 |
|
106 | |||
107 | thread.replies.add(post) |
|
107 | thread.replies.add(post) | |
108 | list(map(thread.add_tag, tags)) |
|
108 | list(map(thread.add_tag, tags)) | |
@@ -111,28 +111,8 b' class PostManager(models.Manager):' | |||||
111 | Thread.objects.process_oldest_threads() |
|
111 | Thread.objects.process_oldest_threads() | |
112 | self.connect_replies(post) |
|
112 | self.connect_replies(post) | |
113 |
|
113 | |||
114 |
|
||||
115 | return post |
|
114 | return post | |
116 |
|
115 | |||
117 | def delete_post(self, post): |
|
|||
118 | """ |
|
|||
119 | Deletes post and update or delete its thread |
|
|||
120 | """ |
|
|||
121 |
|
||||
122 | post_id = post.id |
|
|||
123 |
|
||||
124 | thread = post.get_thread() |
|
|||
125 |
|
||||
126 | if post.is_opening(): |
|
|||
127 | thread.delete() |
|
|||
128 | else: |
|
|||
129 | thread.last_edit_time = timezone.now() |
|
|||
130 | thread.save() |
|
|||
131 |
|
||||
132 | post.delete() |
|
|||
133 |
|
||||
134 | logging.getLogger('boards.post.delete').info('Deleted post #%d (%s)' % (post_id, post.get_title())) |
|
|||
135 |
|
||||
136 | def delete_posts_by_ip(self, ip): |
|
116 | def delete_posts_by_ip(self, ip): | |
137 | """ |
|
117 | """ | |
138 | Deletes all posts of the author with same IP |
|
118 | Deletes all posts of the author with same IP | |
@@ -140,7 +120,7 b' class PostManager(models.Manager):' | |||||
140 |
|
120 | |||
141 | posts = self.filter(poster_ip=ip) |
|
121 | posts = self.filter(poster_ip=ip) | |
142 | for post in posts: |
|
122 | for post in posts: | |
143 |
|
|
123 | post.delete() | |
144 |
|
124 | |||
145 | def connect_replies(self, post): |
|
125 | def connect_replies(self, post): | |
146 | """ |
|
126 | """ | |
@@ -376,12 +356,23 b' class Post(models.Model, Viewable):' | |||||
376 |
|
356 | |||
377 | def delete(self, using=None): |
|
357 | def delete(self, using=None): | |
378 | """ |
|
358 | """ | |
379 | Deletes all post images and the post itself. |
|
359 | Deletes all post images and the post itself. If the post is opening, | |
|
360 | thread with all posts is deleted. | |||
380 | """ |
|
361 | """ | |
381 |
|
362 | |||
382 | self.images.all().delete() |
|
363 | self.images.all().delete() | |
383 |
|
364 | |||
384 | super(Post, self).delete(using) |
|
365 | if self.is_opening(): | |
|
366 | self.get_thread().delete() | |||
|
367 | else: | |||
|
368 | thread = self.get_thread() | |||
|
369 | thread.last_edit_time = timezone.now() | |||
|
370 | thread.save() | |||
|
371 | ||||
|
372 | super(Post, self).delete(using) | |||
|
373 | ||||
|
374 | logging.getLogger('boards.post.delete').info( | |||
|
375 | 'Deleted post P#{}/{}'.format(self.id, self.get_title())) | |||
385 |
|
376 | |||
386 | def get_post_data(self, format_type=DIFF_TYPE_JSON, request=None, |
|
377 | def get_post_data(self, format_type=DIFF_TYPE_JSON, request=None, | |
387 | include_last_update=False): |
|
378 | include_last_update=False): |
@@ -26,7 +26,7 b' class PostTests(TestCase):' | |||||
26 | post = self._create_post() |
|
26 | post = self._create_post() | |
27 | post_id = post.id |
|
27 | post_id = post.id | |
28 |
|
28 | |||
29 |
|
|
29 | post.delete() | |
30 |
|
30 | |||
31 | self.assertFalse(Post.objects.filter(id=post_id).exists()) |
|
31 | self.assertFalse(Post.objects.filter(id=post_id).exists()) | |
32 |
|
32 |
@@ -5,7 +5,6 b' from boards.rss import AllThreadsFeed, T' | |||||
5 | from boards.views import api, tag_threads, all_threads, \ |
|
5 | from boards.views import api, tag_threads, all_threads, \ | |
6 | settings, all_tags |
|
6 | settings, all_tags | |
7 | from boards.views.authors import AuthorsView |
|
7 | from boards.views.authors import AuthorsView | |
8 | from boards.views.delete_post import DeletePostView |
|
|||
9 | from boards.views.ban import BanUserView |
|
8 | from boards.views.ban import BanUserView | |
10 | from boards.views.search import BoardSearchView |
|
9 | from boards.views.search import BoardSearchView | |
11 | from boards.views.static import StaticPageView |
|
10 | from boards.views.static import StaticPageView | |
@@ -38,8 +37,6 b" urlpatterns = patterns(''," | |||||
38 | url(r'^settings/$', settings.SettingsView.as_view(), name='settings'), |
|
37 | url(r'^settings/$', settings.SettingsView.as_view(), name='settings'), | |
39 | url(r'^tags/$', all_tags.AllTagsView.as_view(), name='tags'), |
|
38 | url(r'^tags/$', all_tags.AllTagsView.as_view(), name='tags'), | |
40 | url(r'^authors/$', AuthorsView.as_view(), name='authors'), |
|
39 | url(r'^authors/$', AuthorsView.as_view(), name='authors'), | |
41 | url(r'^delete/(?P<post_id>\w+)/$', DeletePostView.as_view(), |
|
|||
42 | name='delete'), |
|
|||
43 | url(r'^ban/(?P<post_id>\w+)/$', BanUserView.as_view(), name='ban'), |
|
40 | url(r'^ban/(?P<post_id>\w+)/$', BanUserView.as_view(), name='ban'), | |
44 |
|
41 | |||
45 | url(r'^banned/$', views.banned.BannedView.as_view(), name='banned'), |
|
42 | url(r'^banned/$', views.banned.BannedView.as_view(), name='banned'), |
@@ -113,8 +113,6 b' def get_post(request, post_id):' | |||||
113 | in threads list with 'truncated' get parameter. |
|
113 | in threads list with 'truncated' get parameter. | |
114 | """ |
|
114 | """ | |
115 |
|
115 | |||
116 | logger.info('Getting post #%s' % post_id) |
|
|||
117 |
|
||||
118 | post = get_object_or_404(Post, id=post_id) |
|
116 | post = get_object_or_404(Post, id=post_id) | |
119 |
|
117 | |||
120 | context = RequestContext(request) |
|
118 | context = RequestContext(request) |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now