summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-01-13 22:43:07 -0300
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-01-13 22:43:07 -0300
commit1f54fea212c97d0f22a93a41470ba63f792e29cb (patch)
tree2aa775cb1a4d1b8e7536ea65867af18c0c9dd194
parentdc04e4e76efa21df2dc7aa180c6302fdd10abfec (diff)
downloadaskbot-1f54fea212c97d0f22a93a41470ba63f792e29cb.tar.gz
askbot-1f54fea212c97d0f22a93a41470ba63f792e29cb.tar.bz2
askbot-1f54fea212c97d0f22a93a41470ba63f792e29cb.zip
merged adolfos tag subscriptions feature
-rw-r--r--askbot/doc/source/changelog.rst1
-rw-r--r--askbot/media/style/style.less29
-rw-r--r--askbot/models/user.py23
-rw-r--r--askbot/templates/tags/header.html28
-rw-r--r--askbot/templates/tags/list_bulk_tag_subscription.html29
-rw-r--r--askbot/tests/user_model_tests.py11
-rw-r--r--askbot/views/commands.py29
7 files changed, 98 insertions, 52 deletions
diff --git a/askbot/doc/source/changelog.rst b/askbot/doc/source/changelog.rst
index 1fc075c4..572c6aae 100644
--- a/askbot/doc/source/changelog.rst
+++ b/askbot/doc/source/changelog.rst
@@ -5,6 +5,7 @@ Development version
-------------------
* added RSS auto-discovery link
* added support for multilingual site (experimental)
+* tag subscription manager on the tags page (Adolfo)
0.7.47 (Dec 13, 2012)
---------------------
diff --git a/askbot/media/style/style.less b/askbot/media/style/style.less
index f95e46f4..d0cefcb2 100644
--- a/askbot/media/style/style.less
+++ b/askbot/media/style/style.less
@@ -4296,22 +4296,31 @@ textarea.tipped-input {
}
}
-.tag-subscriptions{
+.tag-subscriptions {
border-spacing: 10px;
border-collapse: separate;
- button{
- .button-style(27px, 14px);
+ button {
+ .button-style(27px, 14px);
}
- form{
- display:inline-block;
+ form {
+ display: inline-block;
+ margin-bottom: 0;
+ }
+
+ td {
+ vertical-align: middle;
+ }
+
+ .action {
+ cursor: pointer;
+ color: #4A757F;
+ font-family: 'Open Sans Condensed', Arial, sans-serif;
+ text-decoration: none;
}
- .action{
- cursor: pointer;
- color: #4A757F;
- font-family: 'Open Sans Condensed', Arial, sans-serif;
- text-decoration:none;
+ ul.tags li {
+ margin: 2px 5px;
}
}
diff --git a/askbot/models/user.py b/askbot/models/user.py
index 5fb5b991..cff24b18 100644
--- a/askbot/models/user.py
+++ b/askbot/models/user.py
@@ -596,9 +596,15 @@ class Group(AuthGroup):
class BulkTagSubscriptionManager(BaseQuerySetManager):
- def create(self, tag_names=[],
- user_list=[], group_list=[],
- tag_author=None, **kwargs):
+ def create(
+ self, tag_names=None,
+ user_list=None, group_list=None,
+ tag_author=None, **kwargs
+ ):
+
+ tag_names = tag_names or []
+ user_list = user_list or []
+ group_list = group_list or []
new_object = super(BulkTagSubscriptionManager, self).create(**kwargs)
tag_name_list = []
@@ -611,10 +617,13 @@ class BulkTagSubscriptionManager(BaseQuerySetManager):
tags_id_list= [tag.id for tag in tags]
tag_name_list = [tag.name for tag in tags]
- for tag_name in new_tag_names:
- new_tag = Tag.objects.create(name=tagname, created_by=tag_author)
- tags_id_list.append(new_tag.id)
- tag_name_list.append(new_tag.name)
+ new_tags = Tag.objects.create_in_bulk(
+ tag_names=new_tag_names,
+ user=tag_author
+ )
+
+ tags_id_list.extend([tag.id for tag in new_tags])
+ tag_name_list.extend([tag.name for tag in new_tags])
new_object.tags.add(*tags_id_list)
diff --git a/askbot/templates/tags/header.html b/askbot/templates/tags/header.html
index ba505b63..0832300e 100644
--- a/askbot/templates/tags/header.html
+++ b/askbot/templates/tags/header.html
@@ -23,19 +23,23 @@
{% if tab_id == 'used' %}class="on"{% endif %}
title="{% trans %}sorted by frequency of tag use{% endtrans %}"
><span>{% trans %}by popularity{% endtrans %}</span></a>
- {% if settings.ENABLE_TAG_MODERATION %}
- {% if request.user.is_authenticated() and request.user.is_administrator_or_moderator() %}
- <a
- href="{% url list_suggested_tags %}"
- {% if tab_id == 'suggested' %}class="on"{% endif %}
- title="{% trans %}suggested{% endtrans %}"
- ><span>{% trans %}suggested{% endtrans %}</span></a>
- {% endif %}
+ {% if settings.ENABLE_TAG_MODERATION
+ and request.user.is_authenticated()
+ and request.user.is_administrator_or_moderator()
+ %}
+ <a
+ href="{% url list_suggested_tags %}"
+ {% if tab_id == 'suggested' %}class="on"{% endif %}
+ title="{% trans %}suggested{% endtrans %}"
+ ><span>{% trans %}suggested{% endtrans %}</span></a>
{% endif %}
- {% if request.user.is_authenticated() and request.user.is_administrator() %}
- <a href="{% url list_bulk_tag_subscription %}"
- title="{% trans %}Bulk Tag Subscriptions{% endtrans %}"
- ><span>{% trans %}Manage bulk tag subscriptions{% endtrans %}</span></a>
+ {% if settings.SUBSCRIBED_TAG_SELECTOR_ENABLED
+ and request.user.is_authenticated()
+ and request.user.is_administrator()
+ %}
+ <a href="{% url list_bulk_tag_subscription %}"
+ title="{% trans %}manage subscriptions{% endtrans %}"
+ ><span>{% trans %}manage subscriptions{% endtrans %}</span></a>
{% endif %}
</div>
</div>
diff --git a/askbot/templates/tags/list_bulk_tag_subscription.html b/askbot/templates/tags/list_bulk_tag_subscription.html
index d75323a9..5337154b 100644
--- a/askbot/templates/tags/list_bulk_tag_subscription.html
+++ b/askbot/templates/tags/list_bulk_tag_subscription.html
@@ -21,17 +21,28 @@
<tr>
<td>{{subscription.date_added}}</td>
<td>
- {{
- macros.tag_list_widget(
- subscription.tag_list(),
- deletable=False,
- css_class='subscribed marked-tags'
- )
- }}
+ {{
+ macros.tag_list_widget(
+ subscription.tag_list(),
+ deletable=False,
+ css_class='subscribed marked-tags'
+ )
+ }}
+ </td>
+ {% set comma=joiner(',') %}
+ <td>{%for user in subscription.users.all() %}{{ comma() }}
+ <a
+ href='{% url user_profile user.id, user.username|slugify %}'
+ >{{user.username}}</a>{%endfor%} <a href='#'>
</td>
- <td>{%for user in subscription.users.all() %} <a href='{% url user_profile user.id, user.username|slugify %}'>{{user.username}},</a>{%endfor%} <a href='#'> </td>
{% if settings.GROUPS_ENABLED %}
- <td>{%for group in subscription.groups.all() %} <a href='{% url users_by_group group.id, group.name|slugify %}'>{{group.name}}</a>{%endfor%} </td>
+ {% set comma=joiner(',') %}
+ <td>
+ {% for group in subscription.groups.all() %}{{ comma() }}
+ <a
+ href='{% url users_by_group group.id, group.name|slugify %}'
+ >{{group.name}}</a>{%endfor%}
+ </td>
{%endif%}
<td>
<button type="button"><a class='action' href='{% url edit_bulk_tag_subscription subscription.id %}'>{%trans%}Edit{%endtrans%}</a></button>
diff --git a/askbot/tests/user_model_tests.py b/askbot/tests/user_model_tests.py
index 42c040b0..b11fb151 100644
--- a/askbot/tests/user_model_tests.py
+++ b/askbot/tests/user_model_tests.py
@@ -27,11 +27,14 @@ class UserModelTests(AskbotTestCase):
global_group = models.Group.objects.get_global_group()
+ the_boss = self.create_user('theboss')
bulk_subscription = models.BulkTagSubscription.objects.create(
- tag_names=[one_tag.name, another_tag.name],
- group_list = [global_group]
- )
- user = User.objects.create_user('someone', 'someone@example.com')
+ tag_names=[one_tag.name, another_tag.name],
+ group_list=[global_group],
+ tag_author=the_boss
+ )
+
+ user = self.create_user('someone')
marked_tags = user.get_marked_tags('subscribed')
self.assertTrue(one_tag in marked_tags)
self.assertTrue(another_tag in marked_tags)
diff --git a/askbot/views/commands.py b/askbot/views/commands.py
index 6153a0ca..cd54075e 100644
--- a/askbot/views/commands.py
+++ b/askbot/views/commands.py
@@ -441,7 +441,7 @@ def mark_tag(request, **kwargs):#tagging system
#separate plain tag names and wildcard tags
tagnames, wildcards = forms.clean_marked_tagnames(raw_tagnames)
- if request.user.is_administrator() and post_data['user'] != request.user.id:
+ if request.user.is_administrator() and 'user' in post_data:
user = get_object_or_404(models.User, pk=post_data['user'])
else:
user = request.user
@@ -703,15 +703,17 @@ def subscribe_for_tags(request):
@decorators.admins_only
def list_bulk_tag_subscription(request):
+ if askbot_settings.SUBSCRIBED_TAG_SELECTOR_ENABLED is False:
+ raise Http404
object_list = models.BulkTagSubscription.objects.all()
-
- data = {
- 'object_list': object_list
- }
+ data = {'object_list': object_list}
return render(request, 'tags/list_bulk_tag_subscription.html', data)
@decorators.admins_only
def create_bulk_tag_subscription(request):
+ if askbot_settings.SUBSCRIBED_TAG_SELECTOR_ENABLED is False:
+ raise Http404
+
data = {'action': _('Create')}
if request.method == "POST":
form = forms.BulkTagSubscriptionForm(request.POST)
@@ -721,11 +723,12 @@ def create_bulk_tag_subscription(request):
group_list = form.cleaned_data.get('groups')
bulk_subscription = models.BulkTagSubscription.objects.create(
- tag_names=tag_names,
- tag_author=request.user,
- user_list=user_list,
- group_list=group_list
- )
+ tag_names=tag_names,
+ tag_author=request.user,
+ user_list=user_list,
+ group_list=group_list
+ )
+
return HttpResponseRedirect(reverse('list_bulk_tag_subscription'))
else:
data['form'] = form
@@ -736,6 +739,9 @@ def create_bulk_tag_subscription(request):
@decorators.admins_only
def edit_bulk_tag_subscription(request, pk):
+ if askbot_settings.SUBSCRIBED_TAG_SELECTOR_ENABLED is False:
+ raise Http404
+
bulk_subscription = get_object_or_404(models.BulkTagSubscription,
pk=pk)
data = {'action': _('Edit')}
@@ -785,6 +791,9 @@ def edit_bulk_tag_subscription(request, pk):
@decorators.admins_only
@decorators.post_only
def delete_bulk_tag_subscription(request):
+ if askbot_settings.SUBSCRIBED_TAG_SELECTOR_ENABLED is False:
+ raise Http404
+
pk = request.POST.get('pk')
if pk:
bulk_subscription = get_object_or_404(models.BulkTagSubscription, pk=pk)