Permalink
Browse files

[Fix bug 747421] Add temp page for MozCamp LATAM.

- Adds a temporary view, template, and route at /mozcamp.
- Adds a temporary setting, KEYNOTE_FILE, IT will need to set.
- Revert me soon!
  • Loading branch information...
2 parents 0c2427c + 508dd65 commit aa4a5b9731ddbd03f071378bd220522c519a5070 James Socol committed Apr 20, 2012
@@ -72,7 +72,13 @@ <h1 class="span12">Users in Group "{{ name }}"</h1>
<img class="profile-photo" src="{{ group.steward.photo_url() }}" alt="{{ _('Profile Photo') }}">
</div>
<ul>
- <li><span>{{ group.steward.display_name }}</span></li>
+ <li>
+ <span>
+ <a href="{{ url('profile', group.steward.user.username) }}">
+ {{ group.steward.display_name }}
+ </a>
+ </span>
+ </li>
<li>
<a href="mailto:{{ group.steward.user.email }}">
{{ group.steward.user.email }}
View
@@ -20,9 +20,12 @@
class SearchForm(happyforms.Form):
- q = forms.CharField(widget=forms.HiddenInput, required=True)
+ q = forms.CharField(widget=forms.HiddenInput, required=False)
limit = forms.CharField(widget=forms.HiddenInput, required=False)
- nonvouched_only = forms.BooleanField(required=False)
+ nonvouched_only = forms.BooleanField(label=_lazy(u'Non Vouched Only'),
+ required=False)
+ picture_only = forms.BooleanField(label=_lazy(u'Only users with photos'),
+ required=False)
def clean_limit(self):
"""Validate that this limit is numeric and greater than 1"""
@@ -0,0 +1,31 @@
+{% extends "base.html" %}
+
+{% block page_title %}{{ _('MozCamp LATAM: Keynote') }}{% endblock %}
+{% block body_classes %}box-content{% endblock %}
+
+{% block page_js %}
+ <script type='text/javascript' src='http://videos.mozilla.org/serv/air_mozilla/jwplayer.js'></script>
+ <script>
+ jwplayer('player').setup({
+ 'flashplayer': 'http://videos.mozilla.org/serv/air_mozilla/player.swf',
+ 'file': '{{ settings.KEYNOTE_FILE }}',
+ 'provider': 'rtmp',
+ 'streamer': 'rtmp://fml.1237.edgecastcdn.net/201237/',
+ 'rtmp.subscribe': 'true',
+ 'controlbar': 'over',
+ 'playlist': 'none',
+ 'dock': 'true',
+ 'icons': 'true',
+ 'quality': 'true',
+ 'autostart': 'true',
+ 'width': '620',
+ 'height': '350'
+ });
+ </script>
+{% endblock %}
+
+{% block main_content %}
+ <div style="margin: 30px auto; width: 620px;">
+ <div id="player">Do not adjust your television...</div>
+ </div>
+{% endblock %}
@@ -25,8 +25,22 @@
value="{% if form.cleaned_data %}{{ form.cleaned_data.q }}{% endif %}">
<input type="hidden" name="limit" id="limit" value="{{ limit }}">
<button type="submit" class="btn primary">
+ <span class="icon-search"></span>
{{ _('Search') }}
</button>
+ <button type="button" id="advanced" class="btn primary">
+ <span class="icon-chevron-down"></span>
+ {{ _('Advanced Options') }}
+ </button>
+ <div class="search-options">
+ {% for f in ['nonvouched_only', 'picture_only'] %}
+ <div id="{{ form[f].name }}-container"
+ class="field {{ form[f].field.widget.attrs['class'] }}">
+ {{ form[f] }}
+ {{ form[f].label_tag() }}
+ </div>
+ {% endfor %}
+ </div>
</form>
<div class="well">
{% if not form.cleaned_data %}
@@ -0,0 +1,152 @@
+import os
+
+from django.conf import settings
+
+from nose.tools import eq_
+from pyquery import PyQuery as pq
+
+from common.tests import ESTestCase
+from elasticutils import get_es
+from funfactory.urlresolvers import reverse
+
+from users.models import UserProfile
+
+
+class TestSearch(ESTestCase):
+ def test_search_with_space(self):
+ """Extra spaces should not impact search queries."""
+ amanda = 'Amanda Younger'
+ amandeep = 'Amandeep McIlrath'
+ url = reverse('search')
+ r = self.mozillian_client.get(url, dict(q='Am'))
+ rs = self.mozillian_client.get(url, dict(q=' Am'))
+
+ eq_(r.status_code, 200)
+ peeps = r.context['people']
+ peeps_ws = rs.context['people']
+ saw_amanda = saw_amandeep = False
+
+ for person in peeps:
+ if person.display_name == amanda:
+ saw_amanda = True
+ elif person.display_name == amandeep:
+ saw_amandeep = True
+ if saw_amanda and saw_amandeep:
+ break
+
+ assert peeps[0].id in (peeps_ws[0].id, peeps_ws[1].id)
+ self.assertTrue(saw_amanda, 'We see first person')
+ self.assertTrue(saw_amandeep, 'We see another person')
+
+ def test_nonvouched_search(self):
+ """Make sure that only non vouched users are returned on search."""
+ amanda = 'Amanda Younger'
+ amandeep = 'Amandeep McIlrath'
+ url = reverse('search')
+ r = self.mozillian_client.get(url, dict(q='Am'))
+ rnv = self.mozillian_client.get(url, dict(q='Am', nonvouched_only=1))
+
+ eq_(r.status_code, 200)
+ peeps = r.context['people']
+ peeps_nv = rnv.context['people']
+
+ saw_amanda = saw_amandeep = False
+
+ for person in peeps:
+ if person.display_name == amandeep:
+ assert person.is_vouched, 'Amanda is a Mozillian'
+ saw_amandeep = True
+ elif person.display_name == amanda:
+ if person.is_vouched:
+ self.fail('Amandeep should have pending status')
+ saw_amanda = True
+ if saw_amanda and saw_amandeep:
+ break
+
+ self.assertEqual(peeps_nv[0].display_name, amanda)
+ self.assertTrue(saw_amanda, 'We see vouched users')
+ self.assertTrue(saw_amandeep, 'We see non-vouched users')
+ assert all(not person.is_vouched for person in peeps_nv)
+
+ def test_profilepic_search(self):
+ """Make sure searching for only users with profile pics works."""
+ with open(os.path.join(os.path.dirname(__file__), 'profile-photo.jpg')) as f:
+ r = self.mozillian_client.post(reverse('profile.edit'),
+ dict(first_name='Aman', last_name='Withapic', photo=f))
+
+ if not settings.ES_DISABLED:
+ get_es().refresh(settings.ES_INDEXES['default'], timesleep=0)
+
+ amanhasapic = 'Aman Withapic'
+ amanda = 'Amanda Younger'
+ url = reverse('search')
+ r = self.mozillian_client.get(url, dict(q='Am'))
+ rpp = self.mozillian_client.get(url, dict(q='Am', picture_only=1))
+
+ eq_(r.status_code, 200)
+ peeps = r.context['people']
+ peeps_pp = rpp.context['people']
+ saw_amanda = False
+
+ # Make sure that every body has a profile picture
+ for person in peeps:
+ if person.display_name == amanda:
+ if bool(person.photo):
+ self.fail('Amanda doesnt have a profile pic')
+ saw_amanda = True
+
+ # Make sure amanda shows up in peeps
+ assert amanda in [p.display_name for p in peeps]
+ # Make sure she doesn't show up in peeps_pp
+ assert amanda not in [p.display_name for p in peeps_pp]
+ self.assertEqual(peeps_pp[0].display_name, amanhasapic)
+ self.assertTrue(saw_amanda, 'We dont see profile picture')
+
+ def test_mozillian_search_pagination(self):
+ """Tests the pagination on search.
+
+ 1. assumes no page is passed, but valid limit is passed
+ 2. assumes invalid page is passed, no limit is passed
+ 3. assumes valid page is passed, no limit is passed
+ 4. assumes valid page is passed, valid limit is passed
+ """
+ url = reverse('search')
+ r = self.mozillian_client.get(url, dict(q='Amand', limit='1'))
+ peeps = r.context['people']
+ self.assertEqual(len(peeps), 1)
+
+ r = self.mozillian_client.get(url, dict(q='Amand', page='test'))
+ peeps = r.context['people']
+ self.assertEqual(len(peeps), 2)
+
+ r = self.mozillian_client.get(url, dict(q='Amand', page='1'))
+ peeps = r.context['people']
+ self.assertEqual(len(peeps), 2)
+
+ r = self.mozillian_client.get(url, dict(q='Amand', page='test',
+ limit='1'))
+ peeps = r.context['people']
+ self.assertEqual(len(peeps), 1)
+
+ r = self.mozillian_client.get(url, dict(q='Amand', page='test',
+ limit='x'))
+ peeps = r.context['people']
+ self.assertEqual(len(peeps), 2)
+
+ r = self.mozillian_client.get(url, dict(q='Amand', page='test',
+ limit='-3'))
+ peeps = r.context['people']
+ self.assertEqual(len(peeps), 2)
+
+ def test_empty_query_search(self):
+ """Make sure the search method works with an empty query"""
+ assert UserProfile.search('').count()
+
+ def test_proper_url_arg_handling(self):
+ search_url = reverse('search')
+ r = self.mozillian_client.get(search_url)
+ assert not pq(r.content)('.result')
+
+ r = self.mozillian_client.get(search_url,
+ dict(q=u'', nonvouched_only=1))
+ assert pq(r.content)('.result')
@@ -8,7 +8,7 @@
from nose.tools import eq_
from pyquery import PyQuery as pq
-from common.tests import TestCase, ESTestCase
+from common.tests import TestCase
from funfactory.urlresolvers import set_url_prefix, reverse
@@ -333,78 +333,6 @@ def test_localized_search_plugin(self):
assert '/fr/search' in response.content
-class TestSearch(ESTestCase):
- def test_mozillian_search(self):
- """Test our search."""
- amanda = 'Amanda Younger'
- amandeep = 'Amandeep McIlrath'
- url = reverse('search')
- r = self.mozillian_client.get(url, dict(q='Am'))
- rs = self.mozillian_client.get(url, dict(q=' Am'))
- rnv = self.mozillian_client.get(url, dict(q='Am', nonvouched_only=1))
-
- eq_(r.status_code, 200)
- peeps = r.context['people']
- peeps_ws = rs.context['people']
- peeps_nv = rnv.context['people']
-
- saw_amandeep = saw_amanda = False
-
- for person in peeps:
- if person.display_name == amandeep:
- assert person.is_vouched, 'Amandeep is a Mozillian'
- saw_amandeep = True
- elif person.display_name == amanda:
- if person.is_vouched:
- self.fail('Amanda is pending status')
- saw_amanda = True
- if saw_amandeep and saw_amanda:
- break
-
- assert peeps[0].id in (peeps_ws[0].id, peeps_ws[1].id)
- self.assertEqual(peeps_nv[0].display_name, amanda)
- self.assertTrue(saw_amandeep, 'We see Mozillians')
- self.assertTrue(saw_amanda, 'We see Pending')
-
- assert all(not person.is_vouched for person in peeps_nv)
-
- def test_mozillian_search_pagination(self):
- """Tests the pagination on search.
-
- 1. assumes no page is passed, but valid limit is passed
- 2. assumes invalid page is passed, no limit is passed
- 3. assumes valid page is passed, no limit is passed
- 4. assumes valid page is passed, valid limit is passed
- """
- url = reverse('search')
- r = self.mozillian_client.get(url, dict(q='Amand', limit='1'))
- peeps = r.context['people']
- self.assertEqual(len(peeps), 1)
-
- r = self.mozillian_client.get(url, dict(q='Amand', page='test'))
- peeps = r.context['people']
- self.assertEqual(len(peeps), 2)
-
- r = self.mozillian_client.get(url, dict(q='Amand', page='1'))
- peeps = r.context['people']
- self.assertEqual(len(peeps), 2)
-
- r = self.mozillian_client.get(url, dict(q='Amand', page='test',
- limit='1'))
- peeps = r.context['people']
- self.assertEqual(len(peeps), 1)
-
- r = self.mozillian_client.get(url, dict(q='Amand', page='test',
- limit='x'))
- peeps = r.context['people']
- self.assertEqual(len(peeps), 2)
-
- r = self.mozillian_client.get(url, dict(q='Amand', page='test',
- limit='-3'))
- peeps = r.context['people']
- self.assertEqual(len(peeps), 2)
-
-
def _logged_in_html(response):
doc = pq(response.content)
return doc('a#logout')
View
@@ -19,6 +19,7 @@
url('^opensearch.xml$', views.search_plugin, name='search_plugin'),
url('^search$', views.search, name='search'),
url('^vouch$', views.vouch, name='vouch'),
+ url('^mozcamp$', views.keynote, name='keynote'),
url('^invite$', views.invite, name='invite'),
url('^invited/(?P<id>\d+)$', views.invited, name='invited'),
Oops, something went wrong.

0 comments on commit aa4a5b9

Please sign in to comment.