Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
fixes bug 892514 - URL from upload into Vid.ly shortcutter
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbe committed Jan 30, 2014
1 parent 52bab55 commit 3c6046a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
39 changes: 39 additions & 0 deletions airmozilla/manage/tests/test_views.py
Expand Up @@ -43,6 +43,7 @@
Discussion,
Comment
)
from airmozilla.uploads.models import Upload

from .test_vidly import (
SAMPLE_XML,
Expand Down Expand Up @@ -642,6 +643,44 @@ def test_event_archive(self):
now.strftime('%d %H:%M')
)

def test_event_archive_with_upload(self):
"""event archive an event that came from a suggested event that has
a file upload."""
event = Event.objects.get(title='Test event')
event.archive_time = None
event.save()

upload = Upload.objects.create(
user=self.user,
url='http://s3.com/some.flv',
size=12345
)

now = datetime.datetime.utcnow().replace(tzinfo=utc)
tomorrow = now + datetime.timedelta(days=1)
location = Location.objects.get(id=1)
category = Category.objects.create(name='CATEGORY')
SuggestedEvent.objects.create(
user=self.user,
title='TITLE',
slug='SLUG',
short_description='SHORT DESCRIPTION',
description='DESCRIPTION',
start_time=tomorrow,
location=location,
category=category,
placeholder_img=self.placeholder,
privacy=Event.PRIVACY_CONTRIBUTORS,
first_submitted=now,
accepted=event,
upload=upload
)

url = reverse('manage:event_archive', kwargs={'id': event.id})
response = self.client.get(url)
eq_(response.status_code, 200)
ok_('http://s3.com/some.flv' in response.content)

def test_event_archive_with_vidly_template(self):
"""Event archive page loads and shows correct archive_time behavior."""
vidly_template = Template.objects.create(name='Vid.ly HD')
Expand Down
7 changes: 7 additions & 0 deletions airmozilla/manage/views.py
Expand Up @@ -818,10 +818,17 @@ def event_archive(request, id):
messages.info(request, 'Event "%s" saved.' % event.title)
return redirect('manage:events')
else:

form = forms.EventArchiveForm(instance=event)
initial = dict(email=request.user.email)
if event.privacy != Event.PRIVACY_PUBLIC:
initial['token_protection'] = True
try:
suggested_event = SuggestedEvent.objects.get(accepted=event)
if suggested_event.upload:
initial['url'] = suggested_event.upload.url
except SuggestedEvent.DoesNotExist:
pass
vidly_shortcut_form = forms.VidlyURLForm(
initial=initial,
disable_token_protection=event.privacy != Event.PRIVACY_PUBLIC
Expand Down

0 comments on commit 3c6046a

Please sign in to comment.