##// END OF EJS Templates
Removed archive as a separate entity. Archived threads are saved in the same...
neko259 -
r652:a441eded default
parent child Browse files
Show More
@@ -1,63 +1,62 b''
1 {% load staticfiles %}
1 {% load staticfiles %}
2 {% load i18n %}
2 {% load i18n %}
3 {% load l10n %}
3 {% load l10n %}
4 {% load static from staticfiles %}
4 {% load static from staticfiles %}
5
5
6 <!DOCTYPE html>
6 <!DOCTYPE html>
7 <html>
7 <html>
8 <head>
8 <head>
9 <link rel="stylesheet" type="text/css"
9 <link rel="stylesheet" type="text/css"
10 href="{% static 'css/base.css' %}" media="all"/>
10 href="{% static 'css/base.css' %}" media="all"/>
11 <link rel="stylesheet" type="text/css"
11 <link rel="stylesheet" type="text/css"
12 href="{% static theme_css %}" media="all"/>
12 href="{% static theme_css %}" media="all"/>
13 <link rel="alternate" type="application/rss+xml" href="rss/" title=
13 <link rel="alternate" type="application/rss+xml" href="rss/" title=
14 "{% trans 'Feed' %}"/>
14 "{% trans 'Feed' %}"/>
15
15
16 <link rel="icon" type="image/png"
16 <link rel="icon" type="image/png"
17 href="{% static 'favicon.png' %}">
17 href="{% static 'favicon.png' %}">
18
18
19 <meta name="viewport" content="width=device-width, initial-scale=1"/>
19 <meta name="viewport" content="width=device-width, initial-scale=1"/>
20 <meta charset="utf-8"/>
20 <meta charset="utf-8"/>
21
21
22 {% block head %}{% endblock %}
22 {% block head %}{% endblock %}
23 </head>
23 </head>
24 <body>
24 <body>
25 <script src="{% static 'js/jquery-2.0.1.min.js' %}"></script>
25 <script src="{% static 'js/jquery-2.0.1.min.js' %}"></script>
26 <script src="{% static 'js/jquery-ui-1.10.3.custom.min.js' %}"></script>
26 <script src="{% static 'js/jquery-ui-1.10.3.custom.min.js' %}"></script>
27 <script src="{% static 'js/jquery.mousewheel.js' %}"></script>
27 <script src="{% static 'js/jquery.mousewheel.js' %}"></script>
28 <script src="{% url 'js_info_dict' %}"></script>
28 <script src="{% url 'js_info_dict' %}"></script>
29
29
30 <div class="navigation_panel">
30 <div class="navigation_panel">
31 <a class="link" href="{% url 'index' %}">{% trans "All threads" %}</a>
31 <a class="link" href="{% url 'index' %}">{% trans "All threads" %}</a>
32 {% for tag in tags %}
32 {% for tag in tags %}
33 <a class="tag" href="{% url 'tag' tag_name=tag.name %}"
33 <a class="tag" href="{% url 'tag' tag_name=tag.name %}"
34 >#{{ tag.name }}</a>,
34 >#{{ tag.name }}</a>,
35 {% endfor %}
35 {% endfor %}
36 <a href="{% url 'tags' %}" title="{% trans 'Tag management' %}"
36 <a href="{% url 'tags' %}" title="{% trans 'Tag management' %}"
37 >[...]</a>
37 >[...]</a>
38 <a class="link" href="{% url 'settings' %}">{% trans 'Settings' %}</a>
38 <a class="link" href="{% url 'settings' %}">{% trans 'Settings' %}</a>
39 </div>
39 </div>
40
40
41 {% block content %}{% endblock %}
41 {% block content %}{% endblock %}
42
42
43 <script src="{% static 'js/popup.js' %}"></script>
43 <script src="{% static 'js/popup.js' %}"></script>
44 <script src="{% static 'js/image.js' %}"></script>
44 <script src="{% static 'js/image.js' %}"></script>
45 <script src="{% static 'js/refpopup.js' %}"></script>
45 <script src="{% static 'js/refpopup.js' %}"></script>
46 <script src="{% static 'js/main.js' %}"></script>
46 <script src="{% static 'js/main.js' %}"></script>
47
47
48 <div class="navigation_panel">
48 <div class="navigation_panel">
49 {% block metapanel %}{% endblock %}
49 {% block metapanel %}{% endblock %}
50 [<a href="{% url "login" %}">{% trans 'Login' %}</a>]
50 [<a href="{% url "login" %}">{% trans 'Login' %}</a>]
51 [<a href="{% url "archive" %}">{% trans 'Archive' %}</a>]
52 {% with ppd=posts_per_day|floatformat:2 %}
51 {% with ppd=posts_per_day|floatformat:2 %}
53 {% blocktrans %}Speed: {{ ppd }} posts per day{% endblocktrans %}
52 {% blocktrans %}Speed: {{ ppd }} posts per day{% endblocktrans %}
54 {% endwith %}
53 {% endwith %}
55 <a class="link" href="#top">{% trans 'Up' %}</a>
54 <a class="link" href="#top">{% trans 'Up' %}</a>
56 </div>
55 </div>
57
56
58 <div class="footer">
57 <div class="footer">
59 <!-- Put your banners here -->
58 <!-- Put your banners here -->
60 </div>
59 </div>
61
60
62 </body>
61 </body>
63 </html>
62 </html>
@@ -1,85 +1,81 b''
1 from django.conf.urls import patterns, url, include
1 from django.conf.urls import patterns, url, include
2 from boards import views
2 from boards import views
3 from boards.rss import AllThreadsFeed, TagThreadsFeed, ThreadPostsFeed
3 from boards.rss import AllThreadsFeed, TagThreadsFeed, ThreadPostsFeed
4 from boards.views import api, tag_threads, all_threads, archived_threads, \
4 from boards.views import api, tag_threads, all_threads, \
5 login, settings, all_tags
5 login, settings, all_tags
6 from boards.views.authors import AuthorsView
6 from boards.views.authors import AuthorsView
7 from boards.views.delete_post import DeletePostView
7 from boards.views.delete_post import DeletePostView
8 from boards.views.ban import BanUserView
8 from boards.views.ban import BanUserView
9 from boards.views.static import StaticPageView
9 from boards.views.static import StaticPageView
10 from boards.views.post_admin import PostAdminView
10 from boards.views.post_admin import PostAdminView
11
11
12 js_info_dict = {
12 js_info_dict = {
13 'packages': ('boards',),
13 'packages': ('boards',),
14 }
14 }
15
15
16 urlpatterns = patterns('',
16 urlpatterns = patterns('',
17
17
18 # /boards/
18 # /boards/
19 url(r'^$', all_threads.AllThreadsView.as_view(), name='index'),
19 url(r'^$', all_threads.AllThreadsView.as_view(), name='index'),
20 # /boards/page/
20 # /boards/page/
21 url(r'^page/(?P<page>\w+)/$', all_threads.AllThreadsView.as_view(),
21 url(r'^page/(?P<page>\w+)/$', all_threads.AllThreadsView.as_view(),
22 name='index'),
22 name='index'),
23
23
24 url(r'^archive/$', archived_threads.ArchiveView.as_view(), name='archive'),
25 url(r'^archive/page/(?P<page>\w+)/$',
26 archived_threads.ArchiveView.as_view(), name='archive'),
27
28 # login page
24 # login page
29 url(r'^login/$', login.LoginView.as_view(), name='login'),
25 url(r'^login/$', login.LoginView.as_view(), name='login'),
30
26
31 # /boards/tag/tag_name/
27 # /boards/tag/tag_name/
32 url(r'^tag/(?P<tag_name>\w+)/$', tag_threads.TagView.as_view(),
28 url(r'^tag/(?P<tag_name>\w+)/$', tag_threads.TagView.as_view(),
33 name='tag'),
29 name='tag'),
34 # /boards/tag/tag_id/page/
30 # /boards/tag/tag_id/page/
35 url(r'^tag/(?P<tag_name>\w+)/page/(?P<page>\w+)/$',
31 url(r'^tag/(?P<tag_name>\w+)/page/(?P<page>\w+)/$',
36 tag_threads.TagView.as_view(), name='tag'),
32 tag_threads.TagView.as_view(), name='tag'),
37
33
38 # /boards/thread/
34 # /boards/thread/
39 url(r'^thread/(?P<post_id>\w+)/$', views.thread.ThreadView.as_view(),
35 url(r'^thread/(?P<post_id>\w+)/$', views.thread.ThreadView.as_view(),
40 name='thread'),
36 name='thread'),
41 url(r'^thread/(?P<post_id>\w+)/mode/(?P<mode>\w+)/$', views.thread.ThreadView
37 url(r'^thread/(?P<post_id>\w+)/mode/(?P<mode>\w+)/$', views.thread.ThreadView
42 .as_view(), name='thread_mode'),
38 .as_view(), name='thread_mode'),
43
39
44 # /boards/post_admin/
40 # /boards/post_admin/
45 url(r'^post_admin/(?P<post_id>\w+)/$', PostAdminView.as_view(),
41 url(r'^post_admin/(?P<post_id>\w+)/$', PostAdminView.as_view(),
46 name='post_admin'),
42 name='post_admin'),
47
43
48 url(r'^settings/$', settings.SettingsView.as_view(), name='settings'),
44 url(r'^settings/$', settings.SettingsView.as_view(), name='settings'),
49 url(r'^tags/$', all_tags.AllTagsView.as_view(), name='tags'),
45 url(r'^tags/$', all_tags.AllTagsView.as_view(), name='tags'),
50 url(r'^captcha/', include('captcha.urls')),
46 url(r'^captcha/', include('captcha.urls')),
51 url(r'^authors/$', AuthorsView.as_view(), name='authors'),
47 url(r'^authors/$', AuthorsView.as_view(), name='authors'),
52 url(r'^delete/(?P<post_id>\w+)/$', DeletePostView.as_view(),
48 url(r'^delete/(?P<post_id>\w+)/$', DeletePostView.as_view(),
53 name='delete'),
49 name='delete'),
54 url(r'^ban/(?P<post_id>\w+)/$', BanUserView.as_view(), name='ban'),
50 url(r'^ban/(?P<post_id>\w+)/$', BanUserView.as_view(), name='ban'),
55
51
56 url(r'^banned/$', views.banned.BannedView.as_view(), name='banned'),
52 url(r'^banned/$', views.banned.BannedView.as_view(), name='banned'),
57 url(r'^staticpage/(?P<name>\w+)/$', StaticPageView.as_view(),
53 url(r'^staticpage/(?P<name>\w+)/$', StaticPageView.as_view(),
58 name='staticpage'),
54 name='staticpage'),
59
55
60 # RSS feeds
56 # RSS feeds
61 url(r'^rss/$', AllThreadsFeed()),
57 url(r'^rss/$', AllThreadsFeed()),
62 url(r'^page/(?P<page>\w+)/rss/$', AllThreadsFeed()),
58 url(r'^page/(?P<page>\w+)/rss/$', AllThreadsFeed()),
63 url(r'^tag/(?P<tag_name>\w+)/rss/$', TagThreadsFeed()),
59 url(r'^tag/(?P<tag_name>\w+)/rss/$', TagThreadsFeed()),
64 url(r'^tag/(?P<tag_name>\w+)/page/(?P<page>\w+)/rss/$', TagThreadsFeed()),
60 url(r'^tag/(?P<tag_name>\w+)/page/(?P<page>\w+)/rss/$', TagThreadsFeed()),
65 url(r'^thread/(?P<post_id>\w+)/rss/$', ThreadPostsFeed()),
61 url(r'^thread/(?P<post_id>\w+)/rss/$', ThreadPostsFeed()),
66
62
67 # i18n
63 # i18n
68 url(r'^jsi18n/$', 'boards.views.cached_js_catalog', js_info_dict,
64 url(r'^jsi18n/$', 'boards.views.cached_js_catalog', js_info_dict,
69 name='js_info_dict'),
65 name='js_info_dict'),
70
66
71 # API
67 # API
72 url(r'^api/post/(?P<post_id>\w+)/$', api.get_post, name="get_post"),
68 url(r'^api/post/(?P<post_id>\w+)/$', api.get_post, name="get_post"),
73 url(r'^api/diff_thread/(?P<thread_id>\w+)/(?P<last_update_time>\w+)/$',
69 url(r'^api/diff_thread/(?P<thread_id>\w+)/(?P<last_update_time>\w+)/$',
74 api.api_get_threaddiff, name="get_thread_diff"),
70 api.api_get_threaddiff, name="get_thread_diff"),
75 url(r'^api/threads/(?P<count>\w+)/$', api.api_get_threads,
71 url(r'^api/threads/(?P<count>\w+)/$', api.api_get_threads,
76 name='get_threads'),
72 name='get_threads'),
77 url(r'^api/tags/$', api.api_get_tags, name='get_tags'),
73 url(r'^api/tags/$', api.api_get_tags, name='get_tags'),
78 url(r'^api/thread/(?P<opening_post_id>\w+)/$', api.api_get_thread_posts,
74 url(r'^api/thread/(?P<opening_post_id>\w+)/$', api.api_get_thread_posts,
79 name='get_thread'),
75 name='get_thread'),
80 url(r'^api/add_post/(?P<opening_post_id>\w+)/$', api.api_add_post,
76 url(r'^api/add_post/(?P<opening_post_id>\w+)/$', api.api_add_post,
81 name='add_post'),
77 name='add_post'),
82 url(r'api/get_tag_popularity/(?P<tag_name>\w+)$', api.get_tag_popularity,
78 url(r'api/get_tag_popularity/(?P<tag_name>\w+)$', api.get_tag_popularity,
83 name='get_tag_popularity'),
79 name='get_tag_popularity'),
84
80
85 )
81 )
@@ -1,134 +1,134 b''
1 import string
1 import string
2
2
3 from django.core.urlresolvers import reverse
3 from django.core.urlresolvers import reverse
4 from django.db import transaction
4 from django.db import transaction
5 from django.shortcuts import render, redirect
5 from django.shortcuts import render, redirect
6
6
7 from boards import utils
7 from boards import utils
8 from boards.abstracts.paginator import get_paginator
8 from boards.abstracts.paginator import get_paginator
9 from boards.forms import ThreadForm, PlainErrorList
9 from boards.forms import ThreadForm, PlainErrorList
10 from boards.models import Post, Thread, Ban, Tag
10 from boards.models import Post, Thread, Ban, Tag
11 from boards.views.banned import BannedView
11 from boards.views.banned import BannedView
12 from boards.views.base import BaseBoardView, PARAMETER_FORM
12 from boards.views.base import BaseBoardView, PARAMETER_FORM
13 from boards.views.posting_mixin import PostMixin
13 from boards.views.posting_mixin import PostMixin
14 import neboard
14 import neboard
15
15
16 TAG_DELIMITER = ' '
16 TAG_DELIMITER = ' '
17
17
18 PARAMETER_CURRENT_PAGE = 'current_page'
18 PARAMETER_CURRENT_PAGE = 'current_page'
19 PARAMETER_PAGINATOR = 'paginator'
19 PARAMETER_PAGINATOR = 'paginator'
20 PARAMETER_THREADS = 'threads'
20 PARAMETER_THREADS = 'threads'
21
21
22 TEMPLATE = 'boards/posting_general.html'
22 TEMPLATE = 'boards/posting_general.html'
23 DEFAULT_PAGE = 1
23 DEFAULT_PAGE = 1
24
24
25
25
26 class AllThreadsView(PostMixin, BaseBoardView):
26 class AllThreadsView(PostMixin, BaseBoardView):
27
27
28 user = None
28 user = None
29
29
30 def get(self, request, page=DEFAULT_PAGE, form=None):
30 def get(self, request, page=DEFAULT_PAGE, form=None):
31 context = self.get_context_data(request=request)
31 context = self.get_context_data(request=request)
32
32
33 self.user = context['user']
33 self.user = context['user']
34
34
35 if not form:
35 if not form:
36 form = ThreadForm(error_class=PlainErrorList)
36 form = ThreadForm(error_class=PlainErrorList)
37
37
38 paginator = get_paginator(self.get_threads(),
38 paginator = get_paginator(self.get_threads(),
39 neboard.settings.THREADS_PER_PAGE)
39 neboard.settings.THREADS_PER_PAGE)
40 paginator.current_page = int(page)
40 paginator.current_page = int(page)
41
41
42 threads = paginator.page(page).object_list
42 threads = paginator.page(page).object_list
43
43
44 context[PARAMETER_THREADS] = threads
44 context[PARAMETER_THREADS] = threads
45 context[PARAMETER_FORM] = form
45 context[PARAMETER_FORM] = form
46
46
47 self._get_page_context(paginator, context, page)
47 self._get_page_context(paginator, context, page)
48
48
49 return render(request, TEMPLATE, context)
49 return render(request, TEMPLATE, context)
50
50
51 def post(self, request, page=DEFAULT_PAGE):
51 def post(self, request, page=DEFAULT_PAGE):
52 form = ThreadForm(request.POST, request.FILES,
52 form = ThreadForm(request.POST, request.FILES,
53 error_class=PlainErrorList)
53 error_class=PlainErrorList)
54 form.session = request.session
54 form.session = request.session
55
55
56 if form.is_valid():
56 if form.is_valid():
57 return self.create_thread(request, form)
57 return self.create_thread(request, form)
58 if form.need_to_ban:
58 if form.need_to_ban:
59 # Ban user because he is suspected to be a bot
59 # Ban user because he is suspected to be a bot
60 self._ban_current_user(request)
60 self._ban_current_user(request)
61
61
62 return self.get(request, page, form)
62 return self.get(request, page, form)
63
63
64 @staticmethod
64 @staticmethod
65 def _get_page_context(paginator, context, page):
65 def _get_page_context(paginator, context, page):
66 """
66 """
67 Get pagination context variables
67 Get pagination context variables
68 """
68 """
69
69
70 context[PARAMETER_PAGINATOR] = paginator
70 context[PARAMETER_PAGINATOR] = paginator
71 context[PARAMETER_CURRENT_PAGE] = paginator.page(int(page))
71 context[PARAMETER_CURRENT_PAGE] = paginator.page(int(page))
72
72
73 def parse_tags_string(self, tag_strings):
73 def parse_tags_string(self, tag_strings):
74 """
74 """
75 Parses tag list string and returns tag object list.
75 Parses tag list string and returns tag object list.
76 """
76 """
77
77
78 tags = []
78 tags = []
79
79
80 if tag_strings:
80 if tag_strings:
81 tag_strings = tag_strings.split(TAG_DELIMITER)
81 tag_strings = tag_strings.split(TAG_DELIMITER)
82 for tag_name in tag_strings:
82 for tag_name in tag_strings:
83 tag_name = string.lower(tag_name.strip())
83 tag_name = string.lower(tag_name.strip())
84 if len(tag_name) > 0:
84 if len(tag_name) > 0:
85 tag, created = Tag.objects.get_or_create(name=tag_name)
85 tag, created = Tag.objects.get_or_create(name=tag_name)
86 tags.append(tag)
86 tags.append(tag)
87
87
88 return tags
88 return tags
89
89
90 @transaction.atomic
90 @transaction.atomic
91 def create_thread(self, request, form, html_response=True):
91 def create_thread(self, request, form, html_response=True):
92 """
92 """
93 Creates a new thread with an opening post.
93 Creates a new thread with an opening post.
94 """
94 """
95
95
96 ip = utils.get_client_ip(request)
96 ip = utils.get_client_ip(request)
97 is_banned = Ban.objects.filter(ip=ip).exists()
97 is_banned = Ban.objects.filter(ip=ip).exists()
98
98
99 if is_banned:
99 if is_banned:
100 if html_response:
100 if html_response:
101 return redirect(BannedView().as_view())
101 return redirect(BannedView().as_view())
102 else:
102 else:
103 return
103 return
104
104
105 data = form.cleaned_data
105 data = form.cleaned_data
106
106
107 title = data['title']
107 title = data['title']
108 text = data['text']
108 text = data['text']
109
109
110 text = self._remove_invalid_links(text)
110 text = self._remove_invalid_links(text)
111
111
112 if 'image' in data.keys():
112 if 'image' in data.keys():
113 image = data['image']
113 image = data['image']
114 else:
114 else:
115 image = None
115 image = None
116
116
117 tag_strings = data['tags']
117 tag_strings = data['tags']
118
118
119 tags = self.parse_tags_string(tag_strings)
119 tags = self.parse_tags_string(tag_strings)
120
120
121 post = Post.objects.create_post(title=title, text=text, ip=ip,
121 post = Post.objects.create_post(title=title, text=text, ip=ip,
122 image=image, tags=tags,
122 image=image, tags=tags,
123 user=self._get_user(request))
123 user=self._get_user(request))
124
124
125 if html_response:
125 if html_response:
126 return redirect(post.get_url())
126 return redirect(post.get_url())
127
127
128 def get_threads(self):
128 def get_threads(self):
129 """
129 """
130 Gets list of threads that will be shown on a page.
130 Gets list of threads that will be shown on a page.
131 """
131 """
132
132
133 return Thread.objects.filter(archived=False).order_by('-bump_time')\
133 return Thread.objects.all().order_by('-bump_time')\
134 .exclude(tags__in=self.user.hidden_tags.all()) No newline at end of file
134 .exclude(tags__in=self.user.hidden_tags.all())
@@ -1,86 +1,86 b''
1 from django.shortcuts import get_object_or_404
1 from django.shortcuts import get_object_or_404
2 from boards.models import Tag, Post
2 from boards.models import Tag, Post
3 from boards.views.all_threads import AllThreadsView, DEFAULT_PAGE
3 from boards.views.all_threads import AllThreadsView, DEFAULT_PAGE
4 from boards.views.mixins import DispatcherMixin, RedirectNextMixin
4 from boards.views.mixins import DispatcherMixin, RedirectNextMixin
5 from boards.forms import ThreadForm, PlainErrorList
5 from boards.forms import ThreadForm, PlainErrorList
6
6
7 __author__ = 'neko259'
7 __author__ = 'neko259'
8
8
9
9
10 class TagView(AllThreadsView, DispatcherMixin, RedirectNextMixin):
10 class TagView(AllThreadsView, DispatcherMixin, RedirectNextMixin):
11
11
12 tag_name = None
12 tag_name = None
13
13
14 def get_threads(self):
14 def get_threads(self):
15 tag = get_object_or_404(Tag, name=self.tag_name)
15 tag = get_object_or_404(Tag, name=self.tag_name)
16
16
17 return tag.threads.filter(archived=False).order_by('-bump_time')
17 return tag.threads.all().order_by('-bump_time')
18
18
19 def get_context_data(self, **kwargs):
19 def get_context_data(self, **kwargs):
20 context = super(TagView, self).get_context_data(**kwargs)
20 context = super(TagView, self).get_context_data(**kwargs)
21
21
22 tag = get_object_or_404(Tag, name=self.tag_name)
22 tag = get_object_or_404(Tag, name=self.tag_name)
23 context['tag'] = tag
23 context['tag'] = tag
24
24
25 return context
25 return context
26
26
27 def get(self, request, tag_name, page=DEFAULT_PAGE, form=None):
27 def get(self, request, tag_name, page=DEFAULT_PAGE, form=None):
28 self.tag_name = tag_name
28 self.tag_name = tag_name
29
29
30 dispatch_result = self.dispatch_method(request)
30 dispatch_result = self.dispatch_method(request)
31 if dispatch_result:
31 if dispatch_result:
32 return dispatch_result
32 return dispatch_result
33 else:
33 else:
34 return super(TagView, self).get(request, page, form)
34 return super(TagView, self).get(request, page, form)
35
35
36 def post(self, request, tag_name, page=DEFAULT_PAGE):
36 def post(self, request, tag_name, page=DEFAULT_PAGE):
37 form = ThreadForm(request.POST, request.FILES,
37 form = ThreadForm(request.POST, request.FILES,
38 error_class=PlainErrorList)
38 error_class=PlainErrorList)
39 form.session = request.session
39 form.session = request.session
40
40
41 if form.is_valid():
41 if form.is_valid():
42 return self.create_thread(request, form)
42 return self.create_thread(request, form)
43 if form.need_to_ban:
43 if form.need_to_ban:
44 # Ban user because he is suspected to be a bot
44 # Ban user because he is suspected to be a bot
45 self._ban_current_user(request)
45 self._ban_current_user(request)
46
46
47 return self.get(request, tag_name, page, form)
47 return self.get(request, tag_name, page, form)
48
48
49 def subscribe(self, request):
49 def subscribe(self, request):
50 user = self._get_user(request)
50 user = self._get_user(request)
51 tag = get_object_or_404(Tag, name=self.tag_name)
51 tag = get_object_or_404(Tag, name=self.tag_name)
52
52
53 if not tag in user.fav_tags.all():
53 if not tag in user.fav_tags.all():
54 user.add_tag(tag)
54 user.add_tag(tag)
55
55
56 return self.redirect_to_next(request)
56 return self.redirect_to_next(request)
57
57
58 def unsubscribe(self, request):
58 def unsubscribe(self, request):
59 user = self._get_user(request)
59 user = self._get_user(request)
60 tag = get_object_or_404(Tag, name=self.tag_name)
60 tag = get_object_or_404(Tag, name=self.tag_name)
61
61
62 if tag in user.fav_tags.all():
62 if tag in user.fav_tags.all():
63 user.remove_tag(tag)
63 user.remove_tag(tag)
64
64
65 return self.redirect_to_next(request)
65 return self.redirect_to_next(request)
66
66
67 def hide(self, request):
67 def hide(self, request):
68 """
68 """
69 Adds tag to user's hidden tags. Threads with this tag will not be
69 Adds tag to user's hidden tags. Threads with this tag will not be
70 shown.
70 shown.
71 """
71 """
72
72
73 user = self._get_user(request)
73 user = self._get_user(request)
74 tag = get_object_or_404(Tag, name=self.tag_name)
74 tag = get_object_or_404(Tag, name=self.tag_name)
75
75
76 user.hide_tag(tag)
76 user.hide_tag(tag)
77
77
78 def unhide(self, request):
78 def unhide(self, request):
79 """
79 """
80 Removed tag from user's hidden tags.
80 Removed tag from user's hidden tags.
81 """
81 """
82
82
83 user = self._get_user(request)
83 user = self._get_user(request)
84 tag = get_object_or_404(Tag, name=self.tag_name)
84 tag = get_object_or_404(Tag, name=self.tag_name)
85
85
86 user.unhide_tag(tag)
86 user.unhide_tag(tag)
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