diff options
author | Adolfo Fitoria <adolfo.fitoria@gmail.com> | 2012-08-07 19:28:39 -0600 |
---|---|---|
committer | Adolfo Fitoria <adolfo.fitoria@gmail.com> | 2012-08-07 19:28:39 -0600 |
commit | 16afdc7319db451acec182d1b706d50f2e2b2ed6 (patch) | |
tree | f5b54eb926d0cae636d21639022e5716f8d380bb | |
parent | 460c64735ae3980dce0f094ca2a783e6bc8e0cef (diff) | |
parent | 922c704bee7c79d85eefdf8538edd7e17d02f137 (diff) | |
download | askbot-16afdc7319db451acec182d1b706d50f2e2b2ed6.tar.gz askbot-16afdc7319db451acec182d1b706d50f2e2b2ed6.tar.bz2 askbot-16afdc7319db451acec182d1b706d50f2e2b2ed6.zip |
Merge branch 'user-groups' of github.com:ASKBOT/askbot-devel into user-groups
-rw-r--r-- | askbot/models/__init__.py | 4 | ||||
-rw-r--r-- | askbot/models/tag.py | 7 | ||||
-rw-r--r-- | askbot/models/user.py | 5 | ||||
-rw-r--r-- | askbot/skins/common/media/js/post.js | 14 | ||||
-rw-r--r-- | askbot/skins/common/media/js/user.js | 2 | ||||
-rw-r--r-- | askbot/skins/default/media/style/style.less | 28 | ||||
-rw-r--r-- | askbot/skins/default/templates/macros.html | 2 | ||||
-rw-r--r-- | askbot/skins/default/templates/question/javascript.html | 1 | ||||
-rw-r--r-- | askbot/skins/default/templates/question/sidebar.html | 17 | ||||
-rw-r--r-- | askbot/skins/default/templates/user_profile/user.html | 2 | ||||
-rw-r--r-- | askbot/views/commands.py | 4 | ||||
-rw-r--r-- | askbot/views/users.py | 5 |
12 files changed, 77 insertions, 14 deletions
diff --git a/askbot/models/__init__.py b/askbot/models/__init__.py index d29784b3..96925c69 100644 --- a/askbot/models/__init__.py +++ b/askbot/models/__init__.py @@ -31,7 +31,9 @@ from askbot.models.question import QuestionView, AnonymousQuestion from askbot.models.question import DraftQuestion from askbot.models.question import FavoriteQuestion from askbot.models.tag import Tag, MarkedTag -from askbot.models.tag import get_group_names, get_groups +from askbot.models.tag import get_global_group +from askbot.models.tag import get_group_names +from askbot.models.tag import get_groups from askbot.models.user import EmailFeedSetting, ActivityAuditStatus, Activity from askbot.models.user import GroupMembership, GroupProfile from askbot.models.post import Post, PostRevision diff --git a/askbot/models/tag.py b/askbot/models/tag.py index 539d70f8..b0fd9aac 100644 --- a/askbot/models/tag.py +++ b/askbot/models/tag.py @@ -23,7 +23,8 @@ def get_global_group(): from askbot.models import get_admin return Tag.group_tags.get_or_create( group_name=group_name, - user=get_admin() + user=get_admin(), + is_open=False ) def delete_tags(tags): @@ -307,7 +308,7 @@ class GroupTagManager(BaseQuerySetManager): def get_query_set(self): return GroupTagQuerySet(self.model) - def get_or_create(self, group_name = None, user = None): + def get_or_create(self, group_name = None, user = None, is_open=True): """creates a group tag or finds one, if exists""" #todo: here we might fill out the group profile @@ -321,7 +322,7 @@ class GroupTagManager(BaseQuerySetManager): tag = self.model(name = group_name, created_by = user) tag.save() from askbot.models.user import GroupProfile - group_profile = GroupProfile(group_tag = tag) + group_profile = GroupProfile(group_tag = tag, is_open=is_open) group_profile.save() return tag diff --git a/askbot/models/user.py b/askbot/models/user.py index e4077ea5..14c1d189 100644 --- a/askbot/models/user.py +++ b/askbot/models/user.py @@ -11,6 +11,7 @@ from django.forms import EmailField, URLField from django.utils.translation import ugettext as _ from django.utils.html import strip_tags from askbot import const +from askbot.conf import settings as askbot_settings from askbot.utils import functions from askbot.models.tag import Tag from askbot.forms import DomainNameField @@ -380,6 +381,10 @@ class GroupProfile(models.Model): if user.is_anonymous(): return False + #a special case - automatic global group cannot be joined or left + if self.group_tag.name == askbot_settings.GLOBAL_GROUP_NAME: + return False + if self.is_open: return True diff --git a/askbot/skins/common/media/js/post.js b/askbot/skins/common/media/js/post.js index b79fcef6..88f16e08 100644 --- a/askbot/skins/common/media/js/post.js +++ b/askbot/skins/common/media/js/post.js @@ -3840,6 +3840,20 @@ $(document).ready(function() { var tip = new TippedInput(); tip.decorate(proxyUserEmailInput); } + //if groups are enabled - activate share functions + var groupsInput = $('.share-with-group'); + if (groupsInput.length === 1) { + var groupsAc = new AutoCompleter({ + url: askbot['urls']['getGroupsList'], + preloadData: true, + minChars: 1, + useCache: true, + matchInside: true, + maxCacheLength: 100, + delay: 10 + }); + fakeUserAc.decorate(proxyUserNameInput); + } }); diff --git a/askbot/skins/common/media/js/user.js b/askbot/skins/common/media/js/user.js index 34bdeac5..e858257d 100644 --- a/askbot/skins/common/media/js/user.js +++ b/askbot/skins/common/media/js/user.js @@ -931,7 +931,7 @@ GroupAdderWidget.prototype.decorate = function(element){ this._input = input; var groupsAc = new AutoCompleter({ - url: askbot['urls']['get_groups_list'], + url: askbot['urls']['getGroupsList'], preloadData: true, minChars: 1, useCache: true, diff --git a/askbot/skins/default/media/style/style.less b/askbot/skins/default/media/style/style.less index 4b36a4a0..56461c1f 100644 --- a/askbot/skins/default/media/style/style.less +++ b/askbot/skins/default/media/style/style.less @@ -591,6 +591,7 @@ body.anon { padding-left:5px; border:#c9c9b5 1px solid; height:25px; + font-size: 14px; } #ab-tag-search { width: 138px; @@ -1436,6 +1437,33 @@ ul#related-tags li { } } +.groups-input { + width:152px; + padding-left:5px; + border:#c9c9b5 1px solid; + height:25px; + font-size: 14px; +} + +.add-groups { + border:0; + font-weight:bold; + margin-top:-2px; + .button-style(27px, 14px); + .rounded-corners(4px); +} + +.add-everyone-group { + text-align: center; + margin: auto; + display: block; + padding: 0 10px; +} + +.add-groups:hover { + .button-style-hover; +} + #id_user, #id_user_author { border:#cce6ec 3px solid; diff --git a/askbot/skins/default/templates/macros.html b/askbot/skins/default/templates/macros.html index a640cda9..c03980aa 100644 --- a/askbot/skins/default/templates/macros.html +++ b/askbot/skins/default/templates/macros.html @@ -232,7 +232,7 @@ poor design of the data or methods on data objects #} {%- endmacro -%} {%- macro group_join_button(group_id = None, can_join = False, is_member = False) -%} - {% if can_join or is_member %} + {% if can_join %} <button class="group-join-btn follow-toggle {% if is_member %}on on-state{% endif %}" data-group-id="{{group_id}}" diff --git a/askbot/skins/default/templates/question/javascript.html b/askbot/skins/default/templates/question/javascript.html index 003d7f70..0be3e5a1 100644 --- a/askbot/skins/default/templates/question/javascript.html +++ b/askbot/skins/default/templates/question/javascript.html @@ -18,6 +18,7 @@ askbot['urls']['upvote_comment'] = '{% url upvote_comment %}'; askbot['urls']['delete_post'] = '{% url delete_post %}'; askbot['urls']['get_html_template'] = '{% url get_html_template %}'; + askbot['urls']['getGroupsList'] = '{% url get_groups_list %}'; askbot['messages']['addComment'] = '{% trans %}post a comment{% endtrans %}'; {% if settings.SAVE_COMMENT_ON_ENTER %} askbot['settings']['saveCommentOnEnter'] = true; diff --git a/askbot/skins/default/templates/question/sidebar.html b/askbot/skins/default/templates/question/sidebar.html index 63d25958..30d67c04 100644 --- a/askbot/skins/default/templates/question/sidebar.html +++ b/askbot/skins/default/templates/question/sidebar.html @@ -1,4 +1,4 @@ -{% from "macros.html" import timeago %} +{% import "macros.html" as macros %} {% if settings.SIDEBAR_QUESTION_HEADER %} <div class="box"> {{ settings.SIDEBAR_QUESTION_HEADER }} @@ -46,14 +46,18 @@ <div class="box sharing-widget"> {% if thread.is_private() %} <h2>{% trans %}Share{% endtrans %}</h2> - <p>{% trans %}Share with groups{% endtrans %}</p> + {% if thread.groups.count() %} + <label for="group_name">{% trans %}Shared with groups{% endtrans %}</label> + {% else %} + <label for="group_name">{% trans %}Share with group{% endtrans %}</label> + {% endif %} {% for group in thread.groups.all() %} - <p>{{ group.name }}</p> + <p>{{ macros.user_group(group) }}</p> {% endfor %} <form action="{% url share_question_with_group %}" method="post">{% csrf_token %} - <input type="text" name="group_name" /> + <input type="text" class="groups-input" name="group_name" /> <input type="hidden" name="thread_id" value="{{ thread.id }}"/> - <input type="submit" value="{% trans %}add{% endtrans %}"/> + <input type="submit" class="add-groups" value="{% trans %}add{% endtrans %}"/> </form> <p style="text-align: center">{% trans %}or{% endtrans %}</p> <form action="{% url share_question_with_group %}" method="post">{% csrf_token %} @@ -65,6 +69,7 @@ <input type="hidden" name="thread_id" value="{{ thread.id }}"/> <input type="submit" + class="add-groups add-everyone-group" value="{% trans %}share with everyone{% endtrans %}" /> </form> @@ -80,7 +85,7 @@ <div class="clearfix"></div> <h2>{% trans %}Stats{% endtrans %}</h2> <p> - {% trans %}Asked{% endtrans %}: <strong>{{ timeago(question.added_at) }}</strong> + {% trans %}Asked{% endtrans %}: <strong>{{ macros.timeago(question.added_at) }}</strong> </p> <p> {% trans %}Seen{% endtrans %}: <strong>{{ thread.view_count|intcomma }} {% trans %}times{% endtrans %}</strong> diff --git a/askbot/skins/default/templates/user_profile/user.html b/askbot/skins/default/templates/user_profile/user.html index 2f06a3c9..3aee3cfa 100644 --- a/askbot/skins/default/templates/user_profile/user.html +++ b/askbot/skins/default/templates/user_profile/user.html @@ -24,7 +24,7 @@ askbot['data']['viewUserName'] = '{{ view_user.username|escape }}'; askbot['data']['viewUserId'] = {{view_user.id}}; askbot['urls']['edit_group_membership'] = '{% url edit_group_membership %}'; - askbot['urls']['get_groups_list'] = '{% url get_groups_list %}'; + askbot['urls']['getGroupsList'] = '{% url get_groups_list %}'; </script> {% if request.user|can_moderate_user(view_user) %} <script type='text/javascript' src='{{"/js/jquery.form.js"|media}}'></script> diff --git a/askbot/views/commands.py b/askbot/views/commands.py index 797652a6..64bf8d37 100644 --- a/askbot/views/commands.py +++ b/askbot/views/commands.py @@ -24,6 +24,7 @@ from askbot import models from askbot import forms from askbot.conf import should_show_sort_by_relevance from askbot.conf import settings as askbot_settings +from askbot.models.tag import get_global_group from askbot.utils import category_tree from askbot.utils import decorators from askbot.utils import url_utils @@ -614,8 +615,11 @@ def add_tag_category(request): def get_groups_list(request): """returns names of group tags for the autocomplete function""" + global_group = get_global_group() group_names = models.Tag.group_tags.get_all().filter( deleted = False + ).exclude( + name=global_group.name ).values_list( 'name', flat = True ) diff --git a/askbot/views/users.py b/askbot/views/users.py index 9012a048..5fb581b8 100644 --- a/askbot/views/users.py +++ b/askbot/views/users.py @@ -37,6 +37,7 @@ from askbot.conf import settings as askbot_settings from askbot import models from askbot import exceptions from askbot.models.badges import award_badges_signal +from askbot.models.tag import get_global_group from askbot.skins.loaders import render_into_skin from askbot.templatetags import extra_tags from askbot.search.state_manager import SearchState @@ -56,7 +57,7 @@ def owner_or_moderator_required(f): return f(request, profile_owner, context) return wrapped_func -def show_users(request, by_group = False, group_id = None, group_slug = None): +def show_users(request, by_group=False, group_id=None, group_slug=None): """Users view, including listing of users by group""" users = models.User.objects.exclude(status = 'b') group = None @@ -442,6 +443,8 @@ def user_stats(request, user, context): badges.sort(key=operator.itemgetter(1), reverse=True) user_groups = models.Tag.group_tags.get_for_user(user = user) + global_group = get_global_group() + user_groups = user_groups.exclude(name=global_group.name) if request.user == user: groups_membership_info = user.get_groups_membership_info(user_groups) |