예제 #1
0
def creative(request):
    """Creative Brief page."""
    d = dict(
        promo_dance=absolutify(reverse("flicks.videos.promo_video_dance")),
        promo_noir=absolutify(reverse("flicks.videos.promo_video_noir")),
        promo_twilight=absolutify(reverse("flicks.videos.promo_video_twilight")),
        page_type="secondary",
    )

    return render(request, "creative.html", d)
예제 #2
0
def creative(request):
    """Creative Brief page."""
    d = dict(
        promo_dance=absolutify(reverse('flicks.videos.promo_video_dance')),
        promo_noir=absolutify(reverse('flicks.videos.promo_video_noir')),
        promo_twilight=absolutify(
            reverse('flicks.videos.promo_video_twilight')),
        page_type='secondary'
    )

    return render(request, 'creative.html', d)
예제 #3
0
    def bitly_link(self):
        """Returns a mzl.la shortlink for this video, generating one if one
        doesn't exist.
        """
        if self.bitly_link_db:
            return self.bitly_link_db

        # Generate a URL, remove the locale (let the site handle redirecting
        # to the proper locale), and finally add the domain to the URL.
        url = reverse('flicks.videos.details', kwargs={'video_id': self.id})
        locale, url = split_path(url)
        url = absolutify(url)

        # Don't actually generate a shortlink if we're developing locally.
        if settings.DEV:
            bitly_link = None
        else:
            bitly_link = generate_bitly_link(url)

        # Fallback to long URL if needed.
        if bitly_link is None:
            return url
        else:
            Video.objects.filter(pk=self.pk).update(bitly_link_db=bitly_link)
            return bitly_link
예제 #4
0
def send_video_to_vidly(video):
    """Send a video to vid.ly for processing."""
    shortlink = addMedia(video.upload_url,
                         absolutify(reverse('flicks.videos.notify')))

    if shortlink is None:
        video.state = 'error'
        video.save()
    else:
        video.shortlink = shortlink
        video.state = 'pending'
        video.save()
예제 #5
0
def send_video_to_vidly(video):
    """Send a video to vid.ly for processing."""
    notify_url = absolutify(reverse('flicks.videos.notify',
                                    args=[settings.NOTIFY_KEY]))
    shortlink = addMedia(video.upload_url, notify_url)

    if shortlink is None:
        video.state = 'error'
        video.save()
    else:
        video.shortlink = shortlink
        video.state = 'pending'
        video.save()
예제 #6
0
def send_video_complete_email(video):
    """Send an email to the uploader of a video that the video conversion has
    completed.
    """
    subject = _lazy('Your Firefox Flick is ready!')
    video_url = reverse('flicks.videos.details', kwargs={'video_id': video.id})
    message = render_to_string('videos/notification_email.html', {
        'video_link': absolutify(video_url),
        'flicks_email': settings.DEFAULT_FROM_EMAIL,
        'facebook_link': settings.FACEBOOK_LINK,
        'twitter_link': settings.TWITTER_LINK
    })
    mail.send_mail(subject, message, settings.DEFAULT_FROM_EMAIL,
                   [video.user.email])
예제 #7
0
 def test_with_slash(self):
     """A path starting with a slash does not have an extra slash."""
     eq_(absolutify('/test/path'), 'http://test.com/test/path')
예제 #8
0
 def test_basic(self):
     """Test that the domain is added correctly."""
     eq_(absolutify('test'), 'http://test.com/test')
예제 #9
0
import urllib

from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.staticfiles.storage import staticfiles_storage
from django.utils.hashcompat import md5_constructor

from jingo import register
from jinja2 import Markup

from flicks.base.util import absolutify
from flicks.users.models import UserProfile

GRAVATAR_URL = getattr(settings, 'GRAVATAR_URL', 'https://secure.gravatar.com')
DEFAULT_GRAVATAR = absolutify(staticfiles_storage.url('img/avatar.png'))


@register.function
def gravatar_url(arg, size=80):
    if isinstance(arg, User):
        email = arg.email
    else:  # Treat as email
        email = arg

    url = '%(url)s/avatar/%(email_hash)s?%(options)s' % {
        'url': GRAVATAR_URL,
        'email_hash': md5_constructor(email.lower()).hexdigest(),
        'options': urllib.urlencode({
            's': str(size),
            'd': 'mm'
        })
예제 #10
0
import urllib

from django.conf import settings
from django.contrib.auth.models import User
from django.utils.hashcompat import md5_constructor

from jingo import register
from jinja2 import Markup

from flicks.base.util import absolutify


GRAVATAR_URL = getattr(settings, 'GRAVATAR_URL', 'http://www.gravatar.com')
DEFAULT_GRAVATAR = absolutify(settings.DEFAULT_GRAVATAR)


@register.function
def gravatar_url(arg, size=80):
    if isinstance(arg, User):
        email = arg.email
    else: # Treat as email
        email = arg

    url = '%(url)s/avatar/%(email_hash)s?%(options)s' % {
        'url': GRAVATAR_URL,
        'email_hash': md5_constructor(email.lower()).hexdigest(),
        'options': urllib.urlencode({'s': str(size),
                                     'default': DEFAULT_GRAVATAR})
    }

    return url
예제 #11
0
import urllib

from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.staticfiles.storage import staticfiles_storage
from django.utils.hashcompat import md5_constructor

from jingo import register
from jinja2 import Markup

from flicks.base.util import absolutify
from flicks.users.models import UserProfile


GRAVATAR_URL = getattr(settings, "GRAVATAR_URL", "https://secure.gravatar.com")
DEFAULT_GRAVATAR = absolutify(staticfiles_storage.url("img/avatar.png"))


@register.function
def gravatar_url(arg, size=80):
    if isinstance(arg, User):
        email = arg.email
    else:  # Treat as email
        email = arg

    url = "%(url)s/avatar/%(email_hash)s?%(options)s" % {
        "url": GRAVATAR_URL,
        "email_hash": md5_constructor(email.lower()).hexdigest(),
        "options": urllib.urlencode({"s": str(size), "d": "mm"}),
    }