]> git.openstreetmap.org Git - osqa.git/commitdiff
made some changes to the subscriptions view. works much better now. I was doing...
authorqw3rty <qw3rty@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Fri, 16 Jul 2010 20:37:51 +0000 (20:37 +0000)
committerqw3rty <qw3rty@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Fri, 16 Jul 2010 20:37:51 +0000 (20:37 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@544 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/skins/default/templates/users/subscriptions.html
forum/skins/default/templates/users/subscriptions_management.html
forum/views/users.py

index d115ae218c501ee9190d9e3eedc8d5e49743a25e..573bb0a3a14309efe516af97a828b5c3f631579c 100644 (file)
     <br/>
 
     <div id="navBar"><div class="tabsA">
-        <a HREF="javascript:enableSettings()" {%  if not manage_open %}class="on"{% endif %} id="subscriptions_settings_button">Settings</a>
-        <a HREF="javascript:enableManagement()" {%  if manage_open %}class="on"{% endif %}  id="subscriptions_management_button">Manage</a>
+        <a href='{% url user_subscriptions id=view_user.id slug=view_user.username|slugify %}?tab=settings' id="subscriptions_settings_button"  {%  if not manage_open %}class="on"{% endif %}>Settings</a>
+        <a href='{% url user_subscriptions id=view_user.id slug=view_user.username|slugify %}?tab=manage' id="subscriptions_management_button"  {%  if manage_open %}class="on"{% endif %}>Manage</a>
     </div></div>
 
     <br/>
-    <div id="subscriptions_settings" {% if manage_open %} style="display:none" {% endif %}>
-        {% include "users/subscriptions_settings.html" %}
-    </div>
-    <div id="subscriptions_management" {% if not manage_open %} style="display:none" {% endif %}>
-        {% include "users/subscriptions_management.html" %}
-    </div>
+
+    {% if not manage_open %}
+        <div id="subscriptions_settings" >
+            {% include "users/subscriptions_settings.html" %}
+        </div>
+    {% endif %}
+
+    {% if manage_open %}
+        <div id="subscriptions_management" >
+            {% include "users/subscriptions_management.html" %}
+        </div>
+    {% endif %}
 {% endblock %}
 <!-- end user_subscriptions.html -->
index 2e918dda97ce18735275774b3babe79d19e1c56b..a0d921e2f77cc8358bcf7b7d05b6d1eb6d9e3eca 100644 (file)
@@ -6,9 +6,9 @@
         {% trans "Manage your current subscriptions" %}
         <span style="font-size:11px">
             {% if auto %}
-                <a href='{% url user_subscriptions id=view_user.id slug=view_user.username|slugify %}?auto=False'>{% trans "don't show auto-subscribe" %}</a>
+                <a href='{% url user_subscriptions id=view_user.id slug=view_user.username|slugify %}?auto=False&tab=manage'>{% trans "don't show auto-subscribe" %}</a>
             {% else %}
-                <a href='{% url user_subscriptions id=view_user.id slug=view_user.username|slugify %}?auto=True'>{% trans "show auto-subscribe" %}</a>
+                <a href='{% url user_subscriptions id=view_user.id slug=view_user.username|slugify %}?auto=True&tab=manage'>{% trans "show auto-subscribe" %}</a>
             {% endif %}
         </span>
     </h2>
index 60ad885999f87f165390a27c9d3ea384175b33a0..025fd8c9b757a876049f3ab5b381b68388d825c0 100644 (file)
@@ -26,6 +26,7 @@ from forum.views.readers import QuestionListPaginatorContext, AnswerPaginatorCon
 import time\r
 import datetime\r
 import decorators\r
+import unicodedata\r
 \r
 class UserReputationSort(pagination.SimpleSort):\r
     def apply(self, objects):\r
@@ -320,52 +321,68 @@ def user_favorites(request, user):
 @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 auto == 'True':\r
-        manage_open = True\r
-        show_auto = True\r
-        subscriptions = QuestionSubscription.objects.filter(user=user).order_by('-last_view')        \r
-        # subscriptions = user.subscriptions.all().order_by('-questionsubscription__last_view')\r
-    else:\r
-        manage_open = True\r
-        show_auto = False\r
-        subscriptions = QuestionSubscription.objects.filter(user=user, auto_subscription=False).order_by('-last_view')\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')\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