Permalink
Browse files

merged feature 157 by Paul Backhouse

  • Loading branch information...
evgenyfadeev committed Jun 15, 2012
2 parents bf63654 + 22f7d07 commit 7cafe4b7a02c79f574862f7abbb56c194734fee0
@@ -200,6 +200,21 @@
)
)
+MARKED_TAG_DISPLAY_CHOICES = (
+ ('always', _('Always, for all users')),
+ ('never', _('Never, for all users')),
+ ('when-user-wants', _('Let users decide'))
+)
+settings.register(
+ livesettings.StringValue(
+ FORUM_DATA_RULES,
+ 'MARKED_TAGS_ARE_PUBLIC_WHEN',
+ default = 'always',
+ choices = MARKED_TAG_DISPLAY_CHOICES,
+ description = _('Publicly show user tag selections')
+ )
+)
+
settings.register(
livesettings.BooleanValue(
FORUM_DATA_RULES,
@@ -33,6 +33,9 @@
_('click to see least voted questions')
_('by votes')
_('click to see most voted questions')
+_('interesting')
+_('ignored')
+_('subscribed')
def get_i18n_message(key):
messages = {
@@ -11,6 +11,7 @@ Development version
the feature requires access to the server (Evgeny)
* Added optional top banner to the question page (Evgeny)
* Made "bootstrap mode" default and created instead "large site mode" (Evgeny)
+* Added interesting/ignored/subscribed tags to the user profile page (Paul Backhouse, Evgeny)
0.7.43 (May 14, 2012)
---------------------
@@ -40,6 +40,7 @@ Programming and documentation
* `Jim Tittsler <http://wikieducator.org/User:JimTittsler>`_
* Silvio Heuberger
* `Alexandros <https://github.com/alexandros-z>`_
+* `Paul Backhouse <https://github.com/powlo>`_
Translations
------------
View
@@ -979,6 +979,11 @@ class EditUserForm(forms.Form):
required=False
)
+ show_marked_tags = forms.BooleanField(
+ label=_('Show tag choices'),
+ required=False
+ )
+
birthday = forms.DateField(
label=_('Date of birth'),
help_text=_('will not be shown, used to calculate age, format: YYYY-MM-DD'),
@@ -1009,6 +1014,7 @@ def __init__(self, user, *args, **kwargs):
country = user.country
self.fields['country'].initial = country
self.fields['show_country'].initial = user.show_country
+ self.fields['show_marked_tags'].initial = user.show_marked_tags
if user.date_of_birth is not None:
self.fields['birthday'].initial = user.date_of_birth

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -82,7 +82,7 @@ def get_users_by_text_query(search_query):
)
)
-User.add_to_class('email_isvalid', models.BooleanField(default=False))
+User.add_to_class('email_isvalid', models.BooleanField(default=False)) #@UndefinedVariable
User.add_to_class('email_key', models.CharField(max_length=32, null=True))
#hardcoded initial reputaion of 1, no setting for this one
User.add_to_class('reputation',
@@ -122,6 +122,8 @@ def get_users_by_text_query(search_query):
User.add_to_class('ignored_tags', models.TextField(blank = True))
User.add_to_class('subscribed_tags', models.TextField(blank = True))
User.add_to_class('email_signature', models.TextField(blank = True))
+User.add_to_class('show_marked_tags', models.BooleanField(default = True))
+
User.add_to_class(
'email_tag_filter_strategy',
models.SmallIntegerField(
@@ -237,6 +239,42 @@ def user_get_old_vote_for_post(self, post):
except Vote.MultipleObjectsReturned:
raise AssertionError
+def user_get_marked_tags(self, reason):
+ """reason is a type of mark: good, bad or subscribed"""
+ assert(reason in ('good', 'bad', 'subscribed'))
+ if reason == 'subscribed':
+ if askbot_settings.SUBSCRIBED_TAG_SELECTOR_ENABLED == False:
+ return Tag.objects.none()
+
+ return Tag.objects.filter(
+ user_selections__user = self,
+ user_selections__reason = reason
+ )
+
+MARKED_TAG_PROPERTY_MAP = {
+ 'good': 'interesting_tags',
+ 'bad': 'ignored_tags',
+ 'subscribed': 'subscribed_tags'
+}
+def user_get_marked_tag_names(self, reason):
+ """returns list of marked tag names for a give
+ reason: good, bad, or subscribed
+ will add wildcard tags as well, if used
+ """
+ if reason == 'subscribed':
+ if askbot_settings.SUBSCRIBED_TAG_SELECTOR_ENABLED == False:
+ return list()
+
+ tags = self.get_marked_tags(reason)
+ tag_names = list(tags.values_list('name', flat = True))
+
+ if askbot_settings.USE_WILDCARD_TAGS:
+ attr_name = MARKED_TAG_PROPERTY_MAP[reason]
+ wildcard_tags = getattr(self, attr_name).split()
+ tag_names.extend(wildcard_tags)
+
+ return tag_names
+
def user_has_affinity_to_question(self, question = None, affinity_type = None):
"""returns True if number of tag overlap of the user tag
selection with the question is 0 and False otherwise
@@ -2476,6 +2514,8 @@ def user_is_group_member(self, group = None):
User.add_to_class('get_avatar_url', user_get_avatar_url)
User.add_to_class('get_default_avatar_url', user_get_default_avatar_url)
User.add_to_class('get_gravatar_url', user_get_gravatar_url)
+User.add_to_class('get_marked_tags', user_get_marked_tags)
+User.add_to_class('get_marked_tag_names', user_get_marked_tag_names)
User.add_to_class('strip_email_signature', user_strip_email_signature)
User.add_to_class('get_groups_membership_info', user_get_groups_membership_info)
User.add_to_class('get_anonymous_name', user_get_anonymous_name)
View
@@ -372,6 +372,7 @@ class GroupProfile(models.Model):
)
class Meta:
+ #added to make account merges work properly
app_label = 'askbot'
def can_accept_user(self, user):
@@ -72,6 +72,7 @@ TagDetailBox.prototype.renderFor = function(wildcard){
$.each(me._tag_names, function(idx, name){
var tag = new Tag();
tag.setName(name);
+ tag.setUrlParams(name)
//tag.setLinkable(false);
me._tags.push(tag);
me._tag_list_element.append(tag.getElement());
@@ -1159,6 +1159,10 @@ ul.tags.marked-tags li,
ul#ab-user-tags li {
width: 160px;
margin:5px;
+ margin-left: 0;
+}
+.tags-page ul.tags {
+ margin-left: 5px;
}
ul#related-tags li {
@@ -3293,19 +3297,26 @@ p.signup_p {
.avatar-page li {
display: inline;
}
-.user-profile-page .avatar p {
- margin-bottom: 0px;
-}
-.user-profile-page .tabBar a#stats {
- margin-left: 0;
-}
-.user-profile-page img.gravatar {
- margin: 2px 0 3px 0;
-}
-.user-profile-page h3 {
- padding: 0;
- margin-top: -3px;
+
+.user-profile-page {
+ .avatar p {
+ margin-bottom: 0px;
+ }
+ .tabBar a#stats {
+ margin-left: 0;
+ }
+ img.gravatar {
+ margin: 2px 0 3px 0;
+ }
+ h3 {
+ padding: 0;
+ margin-top: -3px;
+ }
+ ul.tags {
+ margin-left: 5px;
+ }
}
+
.userList {
font-size: 13px;
}
@@ -27,4 +27,4 @@
{% if request.user.is_authenticated() %}
<script type='text/javascript' src='{{"/js/tag_selector.js"|media}}'></script>
{% endif %}
-<script type="text/javascript" src="{{"/js/live_search.js"|media}}"></script>
+<script type="text/javascript" src='{{"/js/live_search.js"|media}}'></script>
@@ -0,0 +1,24 @@
+{% import "macros.html" as macros %}
+
+{% macro tag_selection(tag_names, selection_type) %}
+ <a name="{{selection_type}}-tags"></a>
+ {% spaceless %}
+ <h2>{%
+ trans counter=tag_names|length, type=gettext(selection_type)|capitalize
+ %}<span class="count">{{counter}}</span> {{type}} Tag{%
+ pluralize
+ %}<span class="count">{{counter}}</span> {{type}} Tags{%
+ endtrans
+ %}
+ </h2>
+ {% endspaceless %}
+ <div class="user-stats-table">
+ <table class="tags">
+ <tr>
+ <td valign="top">
+ {{ macros.tag_list_widget(tag_names, deletable = False) }}
+ </td>
+ </tr>
+ </table>
+ </div>
+{% endmacro %}
@@ -96,6 +96,14 @@ <h2>{% trans %}Registered user{% endtrans %}</h2>
<td style="vertical-align:top">{{ form.about.label_tag() }}:</td>
<td>{{ form.about }} <span class="form-error"> {{ form.about.errors }} </span></td>
</tr>
+ {% if marked_tags_setting == 'when-user-wants' %}
+ <tr>
+ <td>{{ form.show_marked_tags.label_tag() }}:</td>
+ <td>{{ form.show_marked_tags }}
+ <span class="form-error">{{ form.show_marked_tags.errors }}</span>
+ </td>
+ </tr>
+ {% endif %}
</table>
<div style="margin:30px 0 60px 0">
<input type="submit" value="{% trans %}Update{% endtrans %}" class="submit" >&nbsp;
@@ -1,5 +1,6 @@
{% extends "user_profile/user.html" %}
{% import "macros.html" as macros %}
+{% import "user_profile/macros.html" as user_profile_macros %}
<!-- user_stats.html -->
{% block profilesection %}
{% trans %}overview{% endtrans %}
@@ -110,6 +111,15 @@ <h2>{% trans counter=user_tags|length %}<span class="count">{{counter}}</span> T
</tr>
</table>
</div>
+ {% if interesting_tag_names %}
+ {{ user_profile_macros.tag_selection(interesting_tag_names, 'interesting') }}
+ {% endif %}
+ {% if ignored_tag_names %}
+ {{ user_profile_macros.tag_selection(ignored_tag_names, 'ignored') }}
+ {% endif %}
+ {% if subscribed_tag_names %}
+ {{ user_profile_macros.tag_selection(subscribed_tag_names, 'subscribed') }}
+ {% endif %}
{% if settings.BADGES_MODE == 'public' %}
<a name="badges"></a>
{% spaceless %}
@@ -164,5 +174,9 @@ <h2>{% trans counter=total_badges %}<span class="count">{{counter}}</span> Badge
});
});
</script>
+ <script type='text/javascript' src='{{"/js/tag_selector.js"|media}}'></script>
+ <script type="text/javascript">
+ askbot['urls']['questions'] = '{% url "questions" %}';
+ </script>
{% endblock %}
<!-- end user_stats.html -->
View
@@ -128,15 +128,15 @@ def users(request, by_group = False, group_id = None, group_slug = None):
models.User.objects.order_by(order_by_parameter),
const.USERS_PAGE_SIZE
)
- base_url = request.path + '?sort=%s&' % sortby
+ base_url = request.path + '?sort=%s&amp;' % sortby
else:
sortby = "reputation"
matching_users = models.get_users_by_text_query(search_query)
objects_list = Paginator(
matching_users.order_by('-reputation'),
const.USERS_PAGE_SIZE
)
- base_url = request.path + '?name=%s&sort=%s&' % (search_query, sortby)
+ base_url = request.path + '?name=%s&amp;sort=%s&amp;' % (search_query, sortby)
try:
users_page = objects_list.page(page)
@@ -297,7 +297,7 @@ def edit_user(request, id):
user.about = sanitize_html(form.cleaned_data['about'])
user.country = form.cleaned_data['country']
user.show_country = form.cleaned_data['show_country']
-
+ user.show_marked_tags = form.cleaned_data['show_marked_tags']
user.save()
# send user updated signal if full fields have been updated
award_badges_signal.send(None,
@@ -308,10 +308,12 @@ def edit_user(request, id):
return HttpResponseRedirect(user.get_profile_url())
else:
form = forms.EditUserForm(user)
+
data = {
'active_tab': 'users',
'page_class': 'user-profile-edit-page',
'form' : form,
+ 'marked_tags_setting': askbot_settings.MARKED_TAGS_ARE_PUBLIC_WHEN,
'support_custom_avatars': ('avatar' in django_settings.INSTALLED_APPS),
'view_user': user,
}
@@ -368,6 +370,18 @@ def user_stats(request, user, context):
order_by('-user_tag_usage_count')[:const.USER_VIEW_DATA_SIZE]
user_tags = list(user_tags) # evaluate
+ when = askbot_settings.MARKED_TAGS_ARE_PUBLIC_WHEN
+ if when == 'always' or \
+ (when == 'when-user-wants' and user.show_marked_tags == True):
+ #refactor into: user.get_marked_tag_names('good'/'bad'/'subscribed')
+ interesting_tag_names = user.get_marked_tag_names('good')
+ ignored_tag_names = user.get_marked_tag_names('bad')
+ subscribed_tag_names = user.get_marked_tag_names('subscribed')
+ else:
+ interesting_tag_names = None
+ ignored_tag_names = None
+ subscribed_tag_names = None
+
# tags = models.Post.objects.filter(author=user).values('id', 'thread', 'thread__tags')
# post_ids = set()
# thread_ids = set()
@@ -453,6 +467,9 @@ def user_stats(request, user, context):
'user_tags' : user_tags,
'user_groups': user_groups,
'groups_membership_info': groups_membership_info,
+ 'interesting_tag_names': interesting_tag_names,
+ 'ignored_tag_names': ignored_tag_names,
+ 'subscribed_tag_names': subscribed_tag_names,
'badges': badges,
'total_badges' : len(badges),
}
@@ -5,6 +5,7 @@ Coffin>=0.3
South>=0.7.1
#-e git+https://github.com/matthiask/south.git#egg=south
oauth2
+Lamson
markdown2
html5lib==0.90
django-keyedcache

0 comments on commit 7cafe4b

Please sign in to comment.