Permalink
Browse files

[bug 829340] Remove contributor forum dashboard.

The welcome dashboard goes along with it as it only had the purpose
of tricking people to join the Contributors group so they could see
the contributor forums dashboard.
  • Loading branch information...
1 parent e8abc3a commit faaf49c9cb661b0da1dfc9030fb2d2faaaf92158 @rlr rlr committed Mar 19, 2013
@@ -12,6 +12,7 @@
from dashboards.personal import GROUP_DASHBOARDS
from sumo.models import ModelBase
from sumo import googleanalytics
+from sumo.urlresolvers import reverse
from wiki.models import Document
@@ -91,3 +92,6 @@ class GroupDashboard(ModelBase):
def __unicode__(self):
return u'%s (%s)' % (self.dashboard, self.parameters)
+
+ def get_absolute_url(self):
+ return reverse('dashboards.group', args=[self.group.id])
@@ -2,10 +2,9 @@
from django.conf import settings
from django.http import HttpResponse
+from django.shortcuts import render
from django.utils.datastructures import SortedDict
-import jingo
-
from announcements.models import Announcement
from dashboards.readouts import (
overview_rows, GROUP_CONTRIBUTOR_READOUTS, GROUP_L10N_READOUTS)
@@ -44,10 +43,12 @@ class QuestionsDashboard(Dashboard):
slug = 'forum'
def render(self):
- return jingo.render(self._request, 'dashboards/questions.html',
- {'actions': model_actions(Answer, self._request),
- 'active_tab': self._id,
- 'announcements': Announcement.get_for_group_id(self._id)})
+ return render(
+ self._request,
+ 'dashboards/questions.html',
+ {'actions': model_actions(Answer, self._request),
+ 'active_tab': self._id,
+ 'announcements': Announcement.get_for_group_id(self._id)})
class LocaleDashboard(Dashboard):
@@ -1,14 +1,5 @@
{# vim: set ts=2 et sts=2 sw=2: #}
<ul id="user-nav" class="sidebar-nav">
- {% if user.groups.filter(name='Contributors').exists() %}
- <li{% if active_tab == 'review' %} class="selected"{% endif %}>
- <a href="{{ url('dashboards.review') }}">{{ _('Review', 'dashboard') }}</a>
- </li>
- {% else %}
- <li{% if active_tab == 'welcome' %} class="selected"{% endif %}>
- <a href="{{ url('dashboards.welcome') }}">{{ _('Welcome', 'dashboard') }}</a>
- </li>
- {% endif %}
{% if user.is_authenticated() %}
<li{% if active_tab == 'my-profile' %} class="selected"{% endif %}>
<a href="{{ profile_url(user) }}">{{ _('My profile') }}</a>
@@ -22,7 +13,7 @@
{% endif %}
{% for dash in dashboards %}
<li{% if dash.group.id == active_tab %} class="selected"{% endif %}>
- <a href="{{ url('dashboards.group', dash.group.id) }}">{{ _(dash.group.name) }}</a>
+ <a href="{{ dash.get_absolute_url() }}">{{ _(dash.group.name) }}</a>
</li>
{% endfor %}
</ul>
@@ -1,24 +0,0 @@
-{# vim: set ts=2 et sts=2 sw=2: #}
-{% extends "dashboards/base.html" %}
-{% from "forums/includes/forum_macros.html" import thread_list with context %}
-{% set title = _('Contributor Forums Dashboard') %}
-{% set dashboard_id = 'forums-dashboard' %}
-{% set active_tab = 'review' %}
-{% set styles = ('wiki', 'forums') %}
-{% set crumbs = [(None, title)] %}
-
-{% block dashboard_content %}
- {% include 'dashboards/includes/announcement_list.html' %}
- {% if threads.object_list %}
- <ol class="threads-columns">
- <li class="type">{{ _('Type') }}</li>
- <li class="title">{{ _('Title') }}</li>
- <li class="author">{{ _('Author') }}</li>
- <li class="replies">{{ _('Replies') }}</li>
- <li class="last-post">{{ _('Last Post') }}</li>
- </ol>
- {{ thread_list(threads) }}
- {% else %}
- <p>{{ _("You haven't participated in any contributor forum threads yet.") }}</p>
- {% endif %}
-{% endblock %}
@@ -1,30 +0,0 @@
-{# vim: set ts=2 et sts=2 sw=2: #}
-{% extends "dashboards/base.html" %}
-{% set title = _('Hello') %}
-{% set dashboard_id = 'welcome-dashboard' %}
-{% set active_tab = 'welcome' %}
-
-{% block dashboard_content %}
- <div id="doc-content">
- {% trans %}
- <p>
- We've got this nifty dashboard to help volunteers keep track of
- contributions such as questions answered, forum discussions and
- article edits. In order to enable it, just click
- <span class="button">Join!</span> below.
- </p>
- <p>
- This will add you to our contributor group and subscribe you to
- announcements from the Firefox Help team.
- </p>
- <p>
- Joining isn't required in order to help other users or to get
- help for yourself.
- </p>
- {% endtrans %}
- </div>
- <form action="{{ url('groups.join_contributors')|urlparams(next=url('dashboards.default')) }}" method="post">
- {{ csrf() }}
- <input type="submit" value="{{ _('Join!') }}" />
- </form>
-{% endblock %}
@@ -2,12 +2,10 @@
from nose.tools import eq_
from pyquery import PyQuery as pq
-from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from announcements.tests import announcement
from dashboards.tests import group_dashboard
-from forums.models import Thread, Forum
from sumo.tests import TestCase
from sumo.urlresolvers import reverse
from users.tests import user, group, profile
@@ -95,84 +93,6 @@ def test_untranslated_detail(self):
self.assertContains(response, untranslated.document.title)
-class ContributorForumDashTests(TestCase):
- fixtures = ['users.json', 'posts.json', 'forums_permissions.json']
-
- def test_no_activity(self):
- """Test the page with no activity."""
- self.client.login(username='rrosario', password='testpass')
- response = self.client.get(reverse('dashboards.review'), follow=True)
- eq_(200, response.status_code)
- doc = pq(response.content)
- eq_(1, len(doc('#forums-dashboard p')))
-
- def test_with_activity(self):
- """Test the page with some activity."""
- self.client.login(username='pcraciunoiu', password='testpass')
- # Verify threads appear on the page
- response = self.client.get(reverse('dashboards.review'), follow=True)
- eq_(200, response.status_code)
- doc = pq(response.content)
- eq_(1, len(doc('ol.threads > li')))
-
- def test_anonymous_user(self):
- """Checks the forums dashboard doesn't load for an anonymous user."""
- self.client.logout()
- response = self.client.get(reverse('dashboards.review',
- locale='en-US'))
- eq_(302, response.status_code)
- assert '/users/login' in response['location']
-
- def test_activity_multiple_forums(self):
- """Checks links are correct when there is activity from >1 forum."""
- jsocol = User.objects.get(username='jsocol')
- rrosario = User.objects.get(username='rrosario')
- forum = Forum.objects.get(slug='another-forum')
- # Create new thread in Another Forum
- thread = Thread(creator=jsocol, title='foobartest', forum=forum)
- thread.save()
- post = thread.new_post(author=jsocol, content='loremipsumdolor')
- post.save()
- # Add a reply
- post = thread.new_post(author=rrosario, content='replyhi')
- post.save()
- # Verify links
- self.client.login(username='jsocol', password='testpass')
- response = self.client.get(reverse('dashboards.review'), follow=True)
- eq_(200, response.status_code)
- doc = pq(response.content)
- links = doc('ol.threads div.title a')
- hrefs = [link.attrib['href'] for link in links]
- eq_(5, len(hrefs))
- for i in range(5):
- if i == 2:
- assert hrefs[i].startswith('/en-US/forums/another-forum/')
- else:
- assert hrefs[i].startswith('/en-US/forums/test-forum/')
-
-
-class AnnouncementForumDashTests(TestCase):
- fixtures = ['users.json']
-
- def setUp(self):
- super(AnnouncementForumDashTests, self).setUp()
- self.client.login(username='jsocol', password='testpass')
- self.creator = User.objects.all()[0]
-
- def test_active(self):
- """Active announcement shows."""
- announcement(creator=self.creator).save()
-
- response = self.client.get(reverse('dashboards.review'), follow=True)
- self.assertContains(response, 'stardate 43124.5')
-
- def test_no_announcements(self):
- """Template renders with no announcements."""
- response = self.client.get(reverse('dashboards.review'), follow=True)
- doc = pq(response.content)
- assert not len(doc('ol.announcements'))
-
-
class GroupLocaleDashTests(TestCase):
def setUp(self):
@@ -216,7 +136,7 @@ def test_for_user_active(self, get_current):
eq_(200, response.status_code)
doc = pq(response.content)
# The locale dash tab shows up.
- eq_(5, len(doc('#user-nav li')))
+ eq_(4, len(doc('#user-nav li')))
# The locale dash tabs shows up and is active
eq_(u'A group', doc('#user-nav li.selected').text())
# The subtitle shows French.
@@ -136,26 +136,3 @@ def test_response_data(self):
eq_(r.document.title, result['data'][0]['data'][0]['title'])
eq_(0.0, result['data'][0]['data'][0]['colorsize'])
eq_('0.00', result['data'][0]['data'][0]['currperc'])
-
-
-class DefaultDashboardRedirect(TestCase):
- def setUp(self):
- super(DefaultDashboardRedirect, self).setUp()
- self.user = user(save=True)
- self.client.login(username=self.user.username, password='testpass')
- self.group = group(name='Contributors', save=True)
-
- def test_redirect_non_contributor(self):
- """Test redirect from /dashboard to dashboard/wecome."""
- r = self.client.get(reverse('dashboards.default', locale='en-US'),
- follow=False)
- eq_(302, r.status_code)
- eq_('http://testserver/en-US/dashboard/welcome', r['location'])
-
- def test_redirect_contributor(self):
- """Test redirect from /dashboard to dashboard/forums."""
- self.user.groups.add(self.group)
- r = self.client.get(reverse('dashboards.default', locale='en-US'),
- follow=False)
- eq_(302, r.status_code)
- eq_('http://testserver/en-US/dashboard/forums', r['location'])
@@ -3,8 +3,6 @@
urlpatterns = patterns('dashboards.views',
url(r'^dashboard$', 'default_dashboard', name='dashboards.default'),
- url(r'^dashboard/welcome$', 'welcome', name='dashboards.welcome'),
- url(r'^dashboard/forums$', 'review', name='dashboards.review'),
url(r'^dashboard/(?P<group_id>\d+)$', 'group_dashboard',
name='dashboards.group'),
url(r'^dashboards/get_helpful_graph_async$', 'get_helpful_graph_async',
@@ -13,17 +13,15 @@
from access.decorators import login_required
from announcements.views import user_can_announce
-from announcements.models import Announcement
-from dashboards.personal import GROUP_DASHBOARDS
+from dashboards.personal import GROUP_DASHBOARDS, personal_dashboards
from dashboards.readouts import (overview_rows, READOUTS, L10N_READOUTS,
CONTRIBUTOR_READOUTS)
from dashboards.utils import render_readouts
-import forums as forum_constants
-from forums.models import Thread
from products.models import Product
from sumo.redis_utils import redis_client, RedisError
from sumo.urlresolvers import reverse
-from sumo.utils import paginate, smart_int
+from sumo.utils import smart_int
+from users.helpers import profile_url
from wiki.models import Locale
@@ -102,8 +100,12 @@ def contributors(request):
"""Render aggregate data about the articles in the default locale."""
product = _get_product(request)
- return render_readouts(request, CONTRIBUTOR_READOUTS, 'contributors.html',
- locale=settings.WIKI_DEFAULT_LANGUAGE, product=product)
+ return render_readouts(
+ request,
+ CONTRIBUTOR_READOUTS,
+ 'contributors.html',
+ locale=settings.WIKI_DEFAULT_LANGUAGE,
+ product=product)
@require_GET
@@ -121,22 +123,6 @@ def wiki_rows(request, readout_slug):
@require_GET
@login_required
-def review(request):
- """Review dashboard for a user, forum threads, announcements, etc."""
- threads = Thread.objects.filter(post__author=request.user).distinct()
- count = threads.count()
- threads = threads.select_related('creator', 'last_post',
- 'last_post__author')
- threads = paginate(request, threads,
- per_page=forum_constants.THREADS_PER_PAGE, count=count)
-
- return render(request, 'dashboards/review.html', {
- 'threads': threads,
- 'announcements': Announcement.get_site_wide()})
-
-
-@require_GET
-@login_required
def group_dashboard(request, group_id):
try:
group = request.user.groups.get(pk=group_id)
@@ -150,17 +136,13 @@ def group_dashboard(request, group_id):
@require_GET
@login_required
def default_dashboard(request):
- if request.user.groups.filter(name='Contributors').exists():
- return HttpResponseRedirect(reverse('dashboards.review'))
+ dashboards = personal_dashboards(request)
+ if len(dashboards) > 0:
+ # Redirect to the first dashboard
+ return HttpResponseRedirect(dashboards[0].get_absolute_url())
else:
- return HttpResponseRedirect(reverse('dashboards.welcome'))
-
-
-@require_GET
-@login_required
-def welcome(request):
- """Welcome dashboard for users not in the Contributors group."""
- return render(request, 'dashboards/welcome.html', {})
+ # Redirect to the profile page
+ return HttpResponseRedirect(profile_url(request.user))
@require_GET

0 comments on commit faaf49c

Please sign in to comment.