Permalink
Browse files

Merge branch 'staging' into dev

  • Loading branch information...
2 parents fc261a4 + 137e450 commit 11dac67b869883ad8a19c22cfebfa083e437456a @cz cz committed Dec 11, 2012
@@ -33,3 +33,30 @@ def email_confirmation_notification(context, force=False):
context['notification_content'] = content
return context
+
+@register.filter
+def show_youtube_prompt(request):
+ """
+ Returns a boolean for whether to show the Youtube syncing prompt.
+
+ Current logic is that we show it for:
+ * unauthenticated visitors
+ * authenticated users who haven't synced a YT account and haven't
+ dismissed the prompt
+ """
+
+ user = request.user if request.user.is_authenticated() else None
+
+ if not user:
+ return True
+
+ if request.COOKIES.get('hide-yt-prompt') == 'yes':
+ return False
+
+ accounts = user.third_party_accounts.all()
+ types = [a.get_type_display() for a in accounts]
+
+ if 'Youtube' not in types:
+ return True
+ else:
+ return False
View
@@ -1438,9 +1438,15 @@ def approve_enabled(self):
@property
def requires_review_or_approval(self):
- """Return wheter we can create tasks for a given workflow."""
+ """Return whether a given workflow requires review or approval."""
return self.approve_enabled or self.review_enabled
+ @property
+ def requires_tasks(self):
+ """Return whether a given workflow requires the use of tasks."""
+ return (self.requires_review_or_approval or self.autocreate_subtitle
+ or self.autocreate_translate)
+
# Tasks
class TaskManager(models.Manager):
View
@@ -145,6 +145,7 @@ def get_errors(self):
output[key] = '/n'.join([force_unicode(i) for i in value])
return output
+
class UserTestResultForm(forms.ModelForm):
class Meta:
@@ -333,4 +334,4 @@ def send(self):
message = self.cleaned_data['message']
from_email = self.cleaned_data['from_email']
to_emails = self.cleaned_data['to_emails']
- send_mail(subject, message, from_email, to_emails)
+ send_mail(subject, message, from_email, to_emails)
View
@@ -964,7 +964,7 @@ def _moderate_language(self, language, user):
return ('public', False) if not team.workflow_enabled else ('private', False)
- if not workflow.requires_review_or_approval:
+ if not workflow.requires_tasks:
return 'public', False
elif language.has_version:
# If there are already active subtitles for this language, we're
@@ -0,0 +1,72 @@
+/*!
+ * jQuery Cookie Plugin v1.3
+ * https://github.com/carhartl/jquery-cookie
+ *
+ * Copyright 2011, Klaus Hartl
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://www.opensource.org/licenses/mit-license.php
+ * http://www.opensource.org/licenses/GPL-2.0
+ */
+(function ($, document, undefined) {
+
+ var pluses = /\+/g;
+
+ function raw(s) {
+ return s;
+ }
+
+ function decoded(s) {
+ return decodeURIComponent(s.replace(pluses, ' '));
+ }
+
+ var config = $.cookie = function (key, value, options) {
+
+ // write
+ if (value !== undefined) {
+ options = $.extend({}, config.defaults, options);
+
+ if (value === null) {
+ options.expires = -1;
+ }
+
+ if (typeof options.expires === 'number') {
+ var days = options.expires, t = options.expires = new Date();
+ t.setDate(t.getDate() + days);
+ }
+
+ value = config.json ? JSON.stringify(value) : String(value);
+
+ return (document.cookie = [
+ encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value),
+ options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
+ options.path ? '; path=' + options.path : '',
+ options.domain ? '; domain=' + options.domain : '',
+ options.secure ? '; secure' : ''
+ ].join(''));
+ }
+
+ // read
+ var decode = config.raw ? raw : decoded;
+ var cookies = document.cookie.split('; ');
+ for (var i = 0, l = cookies.length; i < l; i++) {
+ var parts = cookies[i].split('=');
+ if (decode(parts.shift()) === key) {
+ var cookie = decode(parts.join('='));
+ return config.json ? JSON.parse(cookie) : cookie;
+ }
+ }
+
+ return null;
+ };
+
+ config.defaults = {};
+
+ $.removeCookie = function (key, options) {
+ if ($.cookie(key) !== null) {
+ $.cookie(key, null, options);
+ return true;
+ }
+ return false;
+ };
+
+})(jQuery, document);
View
@@ -500,6 +500,12 @@ var Site = function(Site) {
window.location = $(this).children('option:selected').attr('value');
});
}
+
+ $('#youtube-prompt a.hide').click(function() {
+ $('#youtube-prompt').hide();
+ $.cookie('hide-yt-prompt', 'yes', { expires: 365 });
+ return false;
+ });
},
// Public
View
@@ -708,6 +708,7 @@ def rel(*x):
"js/escape.js",
"js/libs/chosen.jquery.min.js",
"js/libs/chosen.ajax.jquery.js",
+ "js/libs/jquery.cookie.js",
"js/unisubs.site.js",
],
"closure_deps": "",

0 comments on commit 11dac67

Please sign in to comment.