From 92fecfc99bd78efe099c72044901f331e4310599 Mon Sep 17 00:00:00 2001 From: qw3rty Date: Fri, 16 Jul 2010 14:42:51 +0000 Subject: [PATCH] OSQA-266 Put focus on comment text area when clicking "Add new comment" git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@535 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum/skins/default/media/style/style.css | 64 +++++++ .../question_list/subscription_item.html | 11 ++ .../templates/users/subscriptions.html | 179 +++++------------- .../users/subscriptions_management.html | 29 +++ .../users/subscriptions_settings.html | 127 +++++++++++++ forum/templatetags/question_list_tags.py | 19 +- forum/urls.py | 8 +- forum/views/users.py | 48 ++++- 8 files changed, 344 insertions(+), 141 deletions(-) create mode 100644 forum/skins/default/templates/question_list/subscription_item.html create mode 100644 forum/skins/default/templates/users/subscriptions_management.html create mode 100644 forum/skins/default/templates/users/subscriptions_settings.html diff --git a/forum/skins/default/media/style/style.css b/forum/skins/default/media/style/style.css index 3d7ee23..409ce5a 100644 --- a/forum/skins/default/media/style/style.css +++ b/forum/skins/default/media/style/style.css @@ -1521,6 +1521,10 @@ a.comment-edit:hover { background: url("../images/comment-edit-hover.png") no-repeat scroll center center transparent; } +img.subscription-remove { + float:right; +} + .comment-form-container { display: none; padding-top: 12px; @@ -1748,3 +1752,63 @@ div.dialog.prompt .dialog-content select, div.dialog.prompt .dialog-content text height: 14px; display: inline-block; } + +div#subscription_list { + width: 500px; + float:left; +} + +div.subscription_summary { + border-top: 2px dotted #CCCCCE; + overflow: hidden; + padding: 3px 0px 5px 0; + position: relative; + width:100%; + margin-bottom:30px; +} + +div.subscription_title { + float:left; + + width:350px; + + line-height:30px; + + font-size: 25px; + font-weight:bold; + font-family: Arial; +} + +a.subscription_unsubscribe_button { + float:left; + font-size: 15px; + font-weight:bold; + + margin-right:15px; + margin-top:5px; +} + +div.subscription_userinfo { + float:right; +} + +div.subscription_tags { + font-family: sans-serif; + float:left; +} +div.subscription_tags a, span.tag { + background-color: #EEEEEE; + border-bottom: 1px solid #CCCCCC; + border-right: 1px solid #CCCCCC; + color: #777777; + font-size: 11px; + font-weight: normal; + padding: 1px 8px; + text-decoration: none; + white-space: nowrap; +} +div.subscription_tags a:hover { + background-color: #356FCB; + color: #FFFFFF; +} + diff --git a/forum/skins/default/templates/question_list/subscription_item.html b/forum/skins/default/templates/question_list/subscription_item.html new file mode 100644 index 0000000..2aec8e6 --- /dev/null +++ b/forum/skins/default/templates/question_list/subscription_item.html @@ -0,0 +1,11 @@ + + + +{% load i18n humanize extra_filters extra_tags user_tags %} +
+
+ {% trans "Unsubscribe" %} +
+ + +
\ No newline at end of file diff --git a/forum/skins/default/templates/users/subscriptions.html b/forum/skins/default/templates/users/subscriptions.html index a6a93e3..6785cbd 100644 --- a/forum/skins/default/templates/users/subscriptions.html +++ b/forum/skins/default/templates/users/subscriptions.html @@ -1,132 +1,47 @@ -{% extends "user.html" %} - -{% load i18n %} -{% load extra_tags %} -{% load humanize %} - -{% block usercontent %} -

{% trans "Notifications and subscription settings" %}

-

- {% blocktrans %} - Here you can decide which types of notifications you wish to receive, and their frequency.
- {% endblocktrans %} - {% if notificatons_on %} - {% blocktrans %} - Currently you have notifications enabled. You can always stop all notifications without losing your settings and restart them afterwards.
- {% endblocktrans %} - {% else %} - {% blocktrans %} - Currently you have notifications disabled. You can enable them by clicking on the Start notifications button below.
- {% endblocktrans %} - {% endif %} -

-
-
- {{ form.errors }} - - - - - - - - - - - - - - - - - - - - -
- {% trans "Notify me when:" %} -
{% trans "A new member joins" %}{{ form.member_joins }}
{% trans "A new question is posted" %}{{ form.new_question }}
{% trans "A new question matching my interesting tags is posted" %}{{ form.new_question_watched_tags }}
{% trans "There's an update on one of my subscriptions" %}{{ form.subscribed_questions }}
-

 

- - - - - - - - - - - - - - -
- {% trans "Auto subscribe me to:" %} -
- {{ form.questions_asked }}{% trans "Questions I ask" %} - - {{ form.questions_answered }}{% trans "Questions I answer" %} - - {{ form.questions_commented }}{% trans "Questions I comment" %} -
- {{ form.questions_viewed }}{% trans "Questions I view" %} - - {{ form.all_questions_watched_tags }}{% trans "All questions matching my interesting tags" %} - - {{ form.all_questions }}{% trans "All questions" %} -
-

 

- - - - - - - - - - - - -
- {% trans "On my subscriptions, notify me when:" %} -
- {{ form.notify_answers }}{% trans "An answer is posted" %} - - {{ form.notify_comments_own_post }}{% trans "A comment on one of my posts is posted" %} -
- {{ form.notify_comments }}{% trans "A comment is posted" %} - - {{ form.notify_accepted }}{% trans "An answer is accepted" %} -
-

 

- - - - - - - - - - -
- {% trans "More:" %} -
- {{ form.notify_reply_to_comments }}{% trans "Notify me when someone replies to one of my comments on any post using the
@username
notation" %} -
- {{ form.send_digest }}{% trans "Send me the daily digest with information about the site activity" %} -
-
- - {% if notificatons_on %} - - {% else %} - - {% endif %} -
-
-
-{% endblock %} - +{% extends "user.html" %} + +{% load i18n %} +{% load extra_tags %} +{% load humanize %} + +{% block userjs %} + +{% endblock %} + +{% block usercontent %} +
+ + + +
+ + +{% endblock %} + diff --git a/forum/skins/default/templates/users/subscriptions_management.html b/forum/skins/default/templates/users/subscriptions_management.html new file mode 100644 index 0000000..f0f7e9b --- /dev/null +++ b/forum/skins/default/templates/users/subscriptions_management.html @@ -0,0 +1,29 @@ +{% load i18n %} +{% load question_list_tags %} + +
+
+ +
+

+ {% trans "Notifications and subscription settings" %} + + {% if auto %} + {% trans "don't show auto-subscribe" %} + {% else %} + {% trans "show auto-subscribe" %} + {% endif %} + +

+ + {% for subscription in subscriptions.paginator.page %} + {% subscription_list_item subscription %} + {% endfor %} + +
{{ subscriptions.paginator.page_numbers }}
+
+ +
+
+ + diff --git a/forum/skins/default/templates/users/subscriptions_settings.html b/forum/skins/default/templates/users/subscriptions_settings.html new file mode 100644 index 0000000..9c88602 --- /dev/null +++ b/forum/skins/default/templates/users/subscriptions_settings.html @@ -0,0 +1,127 @@ +{% load i18n %} +{% load extra_tags %} +{% load humanize %} + +

{% trans "Notifications and subscription settings" %}

+

+ {% blocktrans %} + Here you can decide which types of notifications you wish to receive, and their frequency.
+ {% endblocktrans %} + {% if notificatons_on %} + {% blocktrans %} + Currently you have notifications enabled. You can always stop all notifications without losing your settings and restart them afterwards.
+ {% endblocktrans %} + {% else %} + {% blocktrans %} + Currently you have notifications disabled. You can enable them by clicking on the Start notifications button below.
+ {% endblocktrans %} + {% endif %} +

+
+
+ {{ form.errors }} + + + + + + + + + + + + + + + + + + + + +
+ {% trans "Notify me when:" %} +
{% trans "A new member joins" %}{{ form.member_joins }}
{% trans "A new question is posted" %}{{ form.new_question }}
{% trans "A new question matching my interesting tags is posted" %}{{ form.new_question_watched_tags }}
{% trans "There's an update on one of my subscriptions" %}{{ form.subscribed_questions }}
+

 

+ + + + + + + + + + + + + + +
+ {% trans "Auto subscribe me to:" %} +
+ {{ form.questions_asked }}{% trans "Questions I ask" %} + + {{ form.questions_answered }}{% trans "Questions I answer" %} + + {{ form.questions_commented }}{% trans "Questions I comment" %} +
+ {{ form.questions_viewed }}{% trans "Questions I view" %} + + {{ form.all_questions_watched_tags }}{% trans "All questions matching my interesting tags" %} + + {{ form.all_questions }}{% trans "All questions" %} +
+

 

+ + + + + + + + + + + + +
+ {% trans "On my subscriptions, notify me when:" %} +
+ {{ form.notify_answers }}{% trans "An answer is posted" %} + + {{ form.notify_comments_own_post }}{% trans "A comment on one of my posts is posted" %} +
+ {{ form.notify_comments }}{% trans "A comment is posted" %} + + {{ form.notify_accepted }}{% trans "An answer is accepted" %} +
+

 

+ + + + + + + + + + +
+ {% trans "More:" %} +
+ {{ form.notify_reply_to_comments }}{% trans "Notify me when someone replies to one of my comments on any post using the
@username
notation" %} +
+ {{ form.send_digest }}{% trans "Send me the daily digest with information about the site activity" %} +
+
+ + {% if notificatons_on %} + + {% else %} + + {% endif %} +
+
+
diff --git a/forum/templatetags/question_list_tags.py b/forum/templatetags/question_list_tags.py index 60cbd7f..41c2539 100644 --- a/forum/templatetags/question_list_tags.py +++ b/forum/templatetags/question_list_tags.py @@ -21,11 +21,28 @@ class QuestionItemNode(template.Node): 'signature_type': self.options.get('signature_type', 'lite'), })) +class SubscriptionItemNode(template.Node): + template = template.loader.get_template('question_list/subscription_item.html') + + def __init__(self, question, options): + self.question = template.Variable(question) + self.options = options + + def render(self, context): + return self.template.render(template.Context({ + 'question': self.question.resolve(context), + 'signature_type': self.options.get('signature_type', 'lite'), + })) + @register.tag def question_list_item(parser, token): tokens = token.split_contents()[1:] return QuestionItemNode(tokens[0], argument_parser(tokens[1:])) - + +@register.tag +def subscription_list_item(parser, token): + tokens = token.split_contents()[1:] + return SubscriptionItemNode(tokens[0], argument_parser(tokens[1:])) @register.inclusion_tag('question_list/sort_tabs.html') def question_sort_tabs(sort_context): diff --git a/forum/urls.py b/forum/urls.py index c7421e9..5cb6594 100644 --- a/forum/urls.py +++ b/forum/urls.py @@ -69,7 +69,7 @@ urlpatterns += patterns('', kwargs=dict(close=True), name='close'), url(r'^%s(?P\d+)/%s$' % (_('questions/'), _('reopen/')), app.commands.close, kwargs=dict(close=False), name='reopen'), - url(r'^%s(?P\d+)/%s$' % (_('questions/'), _('answer/')), app.writers.answer, name='answer'), + url(r'^%s(?P\d+)/%s$' % (_('questions/'), _('answer/')), app.writers.answer, name='answer'), url(r'^%s(?P\w+)/$' % _('pending-data/'), app.writers.manage_pending_data, name='manage_pending_data'), url(r'^%s(?P\d+)/(?P[a-z]+)/' % _('vote/'), app.commands.vote_post, @@ -115,6 +115,9 @@ urlpatterns += patterns('', url(r'^%s$' % _('users/'), app.users.users, name='users'), + url(r'^%s$' % _('online_users/'), app.users.online_users, name='online_users'), + + url(r'^%s(?P\d+)/%s$' % (_('users/'), _('edit/')), app.users.edit_user, name='edit_user'), url(r'^%s(?P\d+)/%s$' % (_('users/'), _('award/')), app.users.award_points, name='user_award_points'), @@ -135,7 +138,6 @@ urlpatterns += patterns('', url(r'^%s(?P\d+)/(?P.+)/%s$' % (_('users/'), _('recent/')), app.users.user_recent, name='user_recent'), url(r'^%s(?P\d+)/(?P.+)/$' % _('users/'), app.users.user_profile, name='user_profile'), - url(r'^%s$' % _('badges/'), app.meta.badges, name='badges'), url(r'^%s(?P\d+)/(?P.+)$' % _('badges/'), app.meta.badge, name='badge'), # (r'^admin/doc/' % _('admin/doc'), include('django.contrib.admindocs.urls')), @@ -199,5 +201,5 @@ urlpatterns += patterns('', url(r'^feeds/rss[/]?$', app.readers.feed, name="latest_questions_feed"), - url(r'^(?P.+)$', app.meta.page, name="static_page") + url(r'^(?P.+)$', app.meta.page, name="static_page"), ) diff --git a/forum/views/users.py b/forum/views/users.py index 306747a..b736e03 100644 --- a/forum/views/users.py +++ b/forum/views/users.py @@ -18,13 +18,13 @@ from forum.forms import * from forum.utils.html import sanitize_html from forum.modules import decorate from datetime import datetime, date -import decorators from forum.actions import EditProfileAction, FavoriteAction, BonusRepAction, SuspendAction from forum.modules import ui from forum.utils import pagination from forum.views.readers import QuestionListPaginatorContext, AnswerPaginatorContext import time +import datetime import decorators class UserReputationSort(pagination.SimpleSort): @@ -40,6 +40,10 @@ class UserListPaginatorContext(pagination.PaginatorContext): (_('name'), pagination.SimpleSort(_('by username'), 'username', _("sorted by username"))), ), pagesizes=(20, 35, 60)) +class SubscriptionListPaginatorContext(pagination.PaginatorContext): + def __init__(self): + super (SubscriptionListPaginatorContext, self).__init__('SUBSCRIPTION_LIST', pagesizes=(5, 10, 20), default_pagesize=20) + class UserAnswersPaginatorContext(pagination.PaginatorContext): def __init__(self): super (UserAnswersPaginatorContext, self).__init__('USER_ANSWER_LIST', sort_methods=( @@ -64,6 +68,20 @@ def users(request): }) +@decorators.render('users/online_users.html', 'online_users', _('Online Users'), weight=200) +def online_users(request): + suser = request.REQUEST.get('q', "") + + one_hour_ago = datetime.datetime.now() - datetime.timedelta(hours=1) + sql_datetime = datetime.datetime.strftime(one_hour_ago, '%Y-%m-%d %H:%M:%S') + users = User.objects.order_by('-last_seen') + + return pagination.paginated(request, ('users', UserListPaginatorContext()), { + "users" : users, + "suser" : suser, + }) + + @login_required def edit_user(request, id): user = get_object_or_404(User, id=id) @@ -299,11 +317,25 @@ def user_favorites(request, user): return {"favorites" : favorites, "view_user" : user} -@user_view('users/subscriptions.html', 'subscriptions', _('subscription settings'), _('subscriptions'), True, tabbed=False) +@user_view('users/subscriptions.html', 'subscriptions', _('subscription'), _('subscriptions'), True, tabbed=False) def user_subscriptions(request, user): enabled = user.subscription_settings.enable_notifications + auto = request.GET.get('auto', 'True') + show_auto = True + manage_open = False + + if len(request.GET) > 0: + manage_open = True + + if auto == 'True': + show_auto = True + subscriptions = user.subscriptions.all().order_by('-questionsubscription__last_view') + else: + show_auto = False + subscriptions = user.subscriptions.filter(questionsubscription__auto_subscription=False).order_by('-questionsubscription__last_view') - if request.method == 'POST': + if request.method == 'POST': + manage_open = False form = SubscriptionSettingsForm(data=request.POST, instance=user.subscription_settings) if form.is_valid(): @@ -325,7 +357,14 @@ def user_subscriptions(request, user): else: form = SubscriptionSettingsForm(instance=user.subscription_settings) - return {'view_user':user, 'notificatons_on': enabled, 'form':form} + return pagination.paginated(request, ('subscriptions', SubscriptionListPaginatorContext()), { + 'subscriptions':subscriptions, + 'view_user':user, + 'notificatons_on': enabled, + 'form':form, + "auto":show_auto, + "manage_open":manage_open + }) @user_view('users/preferences.html', 'preferences', _('preferences'), _('preferences'), True, tabbed=False) def user_preferences(request, user): @@ -356,4 +395,3 @@ def account_settings(request): 'msg': msg, 'is_openid': is_openid }, context_instance=RequestContext(request)) - -- 2.39.5