Merge lp:~mhall119/summit/search-private into lp:summit

Proposed by Michael Hall
Status: Superseded
Proposed branch: lp:~mhall119/summit/search-private
Merge into: lp:summit
Diff against target: 78 lines (+46/-5)
2 files modified
summit/schedule/tests.py (+38/-0)
summit/schedule/views.py (+8/-5)
To merge this branch: bzr merge lp:~mhall119/summit/search-private
Reviewer Review Type Date Requested Status
Summit Hackers Pending
Review via email: mp+131777@code.launchpad.net

This proposal has been superseded by a proposal from 2013-02-27.

Commit message

Show private meetings in search results only if the attendee is participating in that meeting

Description of the change

Show private meetings in search results only if the attendee is participating in that meeting

To post a comment you must log in.
lp:~mhall119/summit/search-private updated
474. By Chris Johnston

[r=] Fixes typo for mouseover stuff

475. By Chris Johnston

[r=daker] Changes the way Summit parses version info

476. By José Antonio Rey

[r=daker] Adding blueprint link to daily, participant, room, and track views.

477. By José Antonio Rey

[r=mhall119] Exposed LP authorization cookie via settings

478. By Adnane Belmadiaf

[r=chrisjohnston] * Added friendly colors for the track block
* Css fixes
* Removed the empty context_processors file

479. By Chris Johnston

[r=daker] Adds field to sponsorship request to require a real name from the user.

480. By Adnane Belmadiaf

[r=mhall119] Transition to login.ubuntu.com

481. By Chris Johnston

[r=mhall119] Adds URL/virt fields, cleans up some tests, pep8 fixes

482. By Chris Johnston

[r=mhall119] A bunch of pep8 fixes and a virt display

483. By Chris Johnston

[r=mhall119] Moves the tests from one long file to a tests/ to start breaking them up logically

484. By Chris Johnston

[r=mhall119] Adds 22 tests for the new virtual meeting functionality.

485. By Chris Johnston

[r=mhall119] Updates copyrights

486. By Michael Hall

[r=chrisjohnston] Adds a placeholder image where the video will be when a broadcast url hasn't been set

487. By Chris Johnston

[r=mhall119] Fixes Google Analytics by adding it as a templatetag

488. By Michael Hall

[r=daker] Don't expose hangout_url over the API

489. By Michael Hall

Update from trunk

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'summit/schedule/tests.py'
2--- summit/schedule/tests.py 2012-10-27 14:59:34 +0000
3+++ summit/schedule/tests.py 2012-10-28 15:07:21 +0000
4@@ -2004,6 +2004,9 @@
5 end_utc=now+one_hour)
6 self.room = factory.make_one(Room)
7
8+ def tearDown(self):
9+ self.client.logout()
10+
11 def test_searchform_exists_on_summit_view(self):
12 ''' Search form should appear on the summit view page '''
13 response = self.client.get(reverse('summit.schedule.views.summit', args=[self.summit.name]))
14@@ -2066,3 +2069,38 @@
15 self.assertContains(response, self.form_html, 1)
16 self.assertContains(response, '<a href="%s">Test Title</a>' % meeting.get_meeting_page_url(), 1)
17
18+ def test_private_meeting_not_shown(self):
19+ ''' Private meetings should not be in the results if the attendee is not attending it'''
20+ now = datetime.datetime.now()
21+ week = datetime.timedelta(days=7)
22+ meeting = factory.make_one(Meeting, summit=self.summit, name='test-name', title='Test Title', requires_dial_in=False, private=True)
23+ user = factory.make_one(User, username='testuser', first_name='Test', last_name='User', is_active=True)
24+ user.set_password('password')
25+ user.save()
26+ attendee = factory.make_one(Attendee, summit=self.summit, user=user, start_utc=now, end_utc=now+week)
27+ participant = factory.make_one(Participant, meeting=meeting, attendee=attendee, participation='ATTENDING', from_launchpad=False)
28+
29+ # Attempt to match 'name' against 'test-name' in Meeting.name
30+ response = self.client.get(reverse('summit.schedule.views.search', args=[self.summit.name]), {'q': 'test'})
31+ self.assertContains(response, self.form_html, 1)
32+ self.assertContains(response, '<a href="%s">Test Title</a>' % meeting.get_meeting_page_url(), 0)
33+
34+ def test_private_meeting_with_attendee_shown(self):
35+ ''' Private meetings should be in the results if the attendee is attending it'''
36+ now = datetime.datetime.now()
37+ week = datetime.timedelta(days=7)
38+ meeting = factory.make_one(Meeting, summit=self.summit, name='test-name', title='Test Title', requires_dial_in=False, private=True)
39+ user = factory.make_one(User, username='testuser', first_name='Test', last_name='User', is_active=True)
40+ user.set_password('password')
41+ user.save()
42+ attendee = factory.make_one(Attendee, summit=self.summit, user=user, start_utc=now, end_utc=now+week)
43+ participant = factory.make_one(Participant, meeting=meeting, attendee=attendee, participation='ATTENDING', from_launchpad=False)
44+
45+ logged_in = self.client.login(username='testuser', password='password')
46+ self.assertTrue(logged_in)
47+
48+ # Attempt to match 'name' against 'test-name' in Meeting.name
49+ response = self.client.get(reverse('summit.schedule.views.search', args=[self.summit.name]), {'q': 'test'})
50+ self.assertContains(response, self.form_html, 1)
51+ self.assertContains(response, '<a href="%s">Test Title</a>' % meeting.get_meeting_page_url(), 1)
52+
53
54=== modified file 'summit/schedule/views.py'
55--- summit/schedule/views.py 2012-10-26 10:23:28 +0000
56+++ summit/schedule/views.py 2012-10-28 15:07:21 +0000
57@@ -81,13 +81,16 @@
58 return render_to_response("schedule/summit.html", context,
59 context_instance=RequestContext(request))
60
61-@summit_only_required
62-def search(request, summit):
63+@summit_required
64+def search(request, summit, attendee):
65 query = request.GET.get('q', None)
66+ meetings = []
67 if query:
68- meetings = summit.meeting_set.filter(Q(name__icontains=query) | Q(title__icontains=query))
69- else:
70- meetings = []
71+ matches = summit.meeting_set.filter(Q(name__icontains=query) | Q(title__icontains=query))
72+ for m in matches:
73+ if not m.private or m.can_view_pm(attendee):
74+ meetings.append(m)
75+
76
77 context = {
78 'summit': summit,

Subscribers

People subscribed via source and target branches