Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Final push #96

Merged
merged 2 commits into from

1 participant

@rossbruniges
  • Google Analytics
  • Copy fixes
  • Fixing the bad edit page fail
@rossbruniges rossbruniges merged commit b6474e8 into mozilla:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 10, 2012
  1. @rossbruniges
Commits on Dec 11, 2012
  1. @rossbruniges
This page is out of date. Refresh to see the latest.
View
12 gameon/base/templates/base.html
@@ -17,6 +17,18 @@
{% block page_css %}{% endblock %}
<link rel="icon" href="{{ static('base/img/favicon.ico') }}" />
{% block social_meta %}{% endblock %}
+ {% if not APP_MSG %}
+ <script type="text/javascript">
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-35433268-16']);
+ _gaq.push(['_trackPageview']);
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+ </script>
+ {% endif %}
</head>
<body id="{% block page_id %}{% endblock %}" class="{% block section_class %}{% endblock %}">
<script type="text/javascript">
View
16 gameon/submissions/forms.py
@@ -1,7 +1,7 @@
from django import forms
from django.forms.models import ModelChoiceField
-from gameon.submissions.widgets import CategorySelectWidget, AdvancedFileInput
+from gameon.submissions.widgets import CategorySelectWidget
from gameon.submissions.models import Entry, Category
@@ -16,7 +16,7 @@
'url': forms.TextInput(attrs={'aria-describedby': 'info_url'}),
'description': forms.Textarea(attrs={'aria-describedby': 'info_description',
'data-maxlength': '1000'}),
- 'thumbnail': AdvancedFileInput(attrs={'aria-describedby': 'info_description'}),
+ 'thumbnail': forms.FileInput(attrs={'aria-describedby': 'info_description'}),
'video_url': forms.TextInput(attrs={'aria-describedby': 'info_description'}),
'team_members': forms.Textarea(attrs={'aria-describedby': 'info_team_members',
'data-maxlength': '250'}),
@@ -36,10 +36,14 @@ def clean_thumbnail(self):
# ensure that people can't upload a HUGE file
# hopefully we can top and tail this with a LimitRequestBody setting in
# apache (http://stackoverflow.com/a/6195637/1308104)
- thumb = self.cleaned_data.get('thumbnail', False)
- if thumb and thumb._size > 2 * 1024 * 1024:
- raise forms.ValidationError("That file is a bit big - please use one under 2mb")
- return thumb
+ thumb = self.cleaned_data.get('thumbnail')
+ if thumb and thumb != False:
+ try:
+ if thumb._size > 2 * 1024 * 1024:
+ raise forms.ValidationError("That file is a bit big - please use one under 2mb")
+ return thumb
+ except AttributeError:
+ return thumb
class Meta:
model = Entry
View
3  gameon/submissions/templates/submissions/create.html
@@ -58,7 +58,8 @@ <h1 class="busta shout">{% block view_title %}Submit Your Game{% endblock %}</h1
<span class="extra meta" id="info_thumbnail">(maximum 2mb file size)</span>
</label>
</div>
- <div>
+ <div class="cf">
+ {% block image_preview %}{% endblock %}
{{ form.thumbnail }}
</div>
</div>
View
8 gameon/submissions/templates/submissions/edit.html
@@ -5,6 +5,14 @@
{% block view_title %}Edit Your Game{% endblock %}
+{% block image_preview %}
+{% if form.thumbnail.value %}
+<p class="meta"><strong>Current image:</strong></p>
+<span class="frame"><img src="{{ MEDIA_URL }}{{ form.thumbnail.value() }}" alt="" /></span>
+<p class="meta">Fancy a change? Feel free to upload a different thumbnail:</p>
+{% endif %}
+{% endblock %}
+
{% block cta_box %}
<span>Ready to edit?</span>
<input type="submit" name="submit" class="cta" value="Edit my Game!" />
View
47 gameon/submissions/widgets.py
@@ -4,53 +4,6 @@
from gameon.submissions.models import Category
-from django.utils.html import escape, conditional_escape
-from django.forms.widgets import ClearableFileInput, CheckboxInput
-
-
-# The ClearableFieldWidget is pretty horrible - trying to make it a bit nicer
-class AdvancedFileInput(ClearableFileInput):
-
- def __init__(self, *args, **kwargs):
-
- self.url_length = kwargs.pop('url_length', 30)
- self.preview = kwargs.pop('preview', True)
- self.image_width = kwargs.pop('image_width', 100)
- super(AdvancedFileInput, self).__init__(*args, **kwargs)
-
- def render(self, name, value, attrs=None,):
-
- substitutions = {
- 'initial_text': "<p class='meta'>Right now you have</p>",
- 'input_text': '<span class="meta">Change this</span>',
- 'clear_template': '',
- 'clear_checkbox_label': '<span class="meta">Delete this</span>',
- }
- template = u'%(input)s'
-
- substitutions['input'] = super(ClearableFileInput, self).render(name, value, attrs)
-
- if value and hasattr(value, "url"):
-
- template = self.template_with_initial
- if self.preview:
- substitutions['initial'] = (u'<span class="frame">\
- <img src="{0}" width="{2}"></span>'.format
- (escape(value.url), '...' + escape(force_unicode(value))[-self.url_length:],
- self.image_width))
- else:
- substitutions['initial'] = (u'<a href="{0}">{1}</a>'.format
- (escape(value.url), '...' + escape(force_unicode(value))[-self.url_length:]))
- if not self.is_required:
- checkbox_name = self.clear_checkbox_name(name)
- checkbox_id = self.clear_checkbox_id(checkbox_name)
- substitutions['clear_checkbox_name'] = conditional_escape(checkbox_name)
- substitutions['clear_checkbox_id'] = conditional_escape(checkbox_id)
- substitutions['clear'] = CheckboxInput().render(checkbox_name, False, attrs={'id': checkbox_id})
- substitutions['clear_template'] = self.template_with_clear % substitutions
-
- return mark_safe(template % substitutions)
-
# Used to display the category description with each category in a RadioSelect widget
class CategorySelectRenderer(RadioFieldRenderer):
Something went wrong with that request. Please try again.