import time\r
import datetime\r
import decorators\r
+import unicodedata\r
\r
class UserReputationSort(pagination.SimpleSort):\r
def apply(self, objects):\r
})\r
\r
\r
-@decorators.render('users/online_users.html', 'online_users', _('Online Users'), weight=200)\r
+#@decorators.render('users/online_users.html', 'online_users', _('Online Users'), weight=200)\r
def online_users(request):\r
suser = request.REQUEST.get('q', "")\r
\r
@user_view('users/subscriptions.html', 'subscriptions', _('subscription'), _('subscriptions'), True, tabbed=False)\r
def user_subscriptions(request, user):\r
enabled = user.subscription_settings.enable_notifications\r
- auto = request.GET.get('auto', 'True')\r
- show_auto = True\r
- manage_open = False\r
- \r
- if len(request.GET) > 0:\r
- manage_open = True\r
- \r
- if auto == 'True':\r
- show_auto = True\r
- subscriptions = user.subscriptions.all().order_by('-questionsubscription__last_view')\r
- else:\r
- show_auto = False\r
- subscriptions = user.subscriptions.filter(questionsubscription__auto_subscription=False).order_by('-questionsubscription__last_view')\r
\r
- if request.method == 'POST':\r
+ tab = request.GET.get('tab', "settings")\r
+\r
+ if tab == 'settings':\r
manage_open = False\r
- form = SubscriptionSettingsForm(data=request.POST, instance=user.subscription_settings)\r
+ if request.method == 'POST':\r
+ manage_open = False\r
+ form = SubscriptionSettingsForm(data=request.POST, instance=user.subscription_settings)\r
+\r
+ if form.is_valid():\r
+ form.save()\r
+ message = _('New subscription settings are now saved')\r
+\r
+ if 'notswitch' in request.POST:\r
+ enabled = not enabled\r
+\r
+ if enabled:\r
+ message = _('Notifications are now enabled')\r
+ else:\r
+ message = _('Notifications are now disabled')\r
+\r
+ user.subscription_settings.enable_notifications = enabled\r
+ user.subscription_settings.save()\r
+\r
+ request.user.message_set.create(message=message)\r
+ else:\r
+ form = SubscriptionSettingsForm(instance=user.subscription_settings)\r
+\r
+ return {\r
+ 'view_user':user,\r
+ 'notificatons_on': enabled,\r
+ 'form':form,\r
+ 'manage_open':manage_open,\r
+ }\r
+\r
+ elif tab == 'manage':\r
+ manage_open = True\r
+\r
+ auto = request.GET.get('auto', 'True')\r
+ if auto == 'True':\r
+ show_auto = True\r
+ subscriptions = QuestionSubscription.objects.filter(user=user).order_by('-last_view')\r
+ else:\r
+ show_auto = False\r
+ subscriptions = QuestionSubscription.objects.filter(user=user, auto_subscription=False).order_by('-last_view')\r
+\r
+ return pagination.paginated(request, ('subscriptions', SubscriptionListPaginatorContext()), {\r
+ 'subscriptions':subscriptions,\r
+ 'view_user':user,\r
+ "auto":show_auto,\r
+ 'manage_open':manage_open,\r
+ })\r
+\r
+ # else:\r
+ # todo: probably want to throw an error\r
+ # error = "error to throw"\r
+\r
\r
- if form.is_valid():\r
- form.save()\r
- message = _('New subscription settings are now saved')\r
\r
- if 'notswitch' in request.POST:\r
- enabled = not enabled\r
\r
- if enabled:\r
- message = _('Notifications are now enabled')\r
- else:\r
- message = _('Notifications are now disabled')\r
\r
- user.subscription_settings.enable_notifications = enabled\r
- user.subscription_settings.save()\r
\r
- request.user.message_set.create(message=message)\r
- else:\r
- form = SubscriptionSettingsForm(instance=user.subscription_settings)\r
-\r
- return pagination.paginated(request, ('subscriptions', SubscriptionListPaginatorContext()), {\r
- 'subscriptions':subscriptions,\r
- 'view_user':user,\r
- 'notificatons_on': enabled,\r
- 'form':form,\r
- "auto":show_auto,\r
- "manage_open":manage_open\r
- })\r
\r
@user_view('users/preferences.html', 'preferences', _('preferences'), _('preferences'), True, tabbed=False)\r
def user_preferences(request, user):\r