Commits

Richard Jones committed b88b01c

cleaning up static / media url and file stuff

Comments (0)

Files changed (12)

pyweek/challenge/media/challenge.css

 	padding: 0px;
 	font: 13px sans-serif;
 	color: #212121;
-	background: #e6ce84 url(img01.jpg) repeat-x left top;
+	background: #ccc;
 }
 
 h1 {

pyweek/challenge/models.py

 class Rating(models.Model):
     entry = models.ForeignKey(Entry)
     user = models.ForeignKey(User)
-    fun = models.PositiveIntegerField(choices=RATING_CHOICES)
-    innovation = models.PositiveIntegerField(choices=RATING_CHOICES)
-    production = models.PositiveIntegerField(choices=RATING_CHOICES)
+    fun = models.PositiveIntegerField(choices=RATING_CHOICES, default=3)
+    innovation = models.PositiveIntegerField(choices=RATING_CHOICES, default=3)
+    production = models.PositiveIntegerField(choices=RATING_CHOICES, default=3)
     nonworking = models.BooleanField()
     disqualify = models.BooleanField()
     comment = models.TextField()

pyweek/challenge/templates/base.html

 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
 <html>
 <head>
-    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> 
-    <link rel="stylesheet" href="http://media.pyweek.org/static/challenge.css" type="text/css">
+    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+    <link rel="stylesheet" href="{{ STATIC_URL }}challenge.css" type="text/css">
     <link rel="alternate" type="application/rss+xml"
        title="PyWeek Diaries RSS feed"
-       href="http://media.pyweek.org/rss/diaries.rss">
-    <script src="http://media.pyweek.org/static/js/challenge.js" type="text/javascript"></script>
-    <script src="http://media.pyweek.org/static/js/jquery.min.js" type="text/javascript"></script>
+       href="{{ MEDIA_URL }}rss/diaries.rss">
+       <script src="{{ STATIC_URL }}js/challenge.js" type="text/javascript"></script>
+       <script src="{{ STATIC_URL }}js/jquery.min.js" type="text/javascript"></script>
     {% block links %}
     {% endblock %}
     <title>{% block title %}{% endblock %}</title>
 <body>
 <div id="header">
  <div id="logo">
-    <A href="/"><IMG border="0" src="http://media.pyweek.org/static/pyweek.png"></A></span>
+     <a href="/"><img border="0" src="{{ STATIC_URL }}pyweek.png"></a></span>
  </div>
  <div id="menu">
   <ul id="cssdropdown">
   </ul>
 
   <ul id="cssdropdown">
-
     <li class="headlink">
          {% if not latest.isCompStarted %}
             <A href="/{{ latest.number }}/">Next Challenge</A>
           {% for one in all reversed %}
              <li><a title="{{ one.title|escape }}" href="/{{ one.number }}/">{{ one.start|date:"F Y" }}</a></li>
           {% endfor %}
-          <li><a href="http://media.pyweek.org/static/pygame.draw-0606.html">June 2006 (mini)</a></li>
+          <li><a href="{{ STATIC_URL }}pygame.draw-0606.html">June 2006 (mini)</a></li>
           <li><a href="http://www.mechanicalcat.net/tech/PyWeek/1">August 2005</a></li>
       </ul>
 
 
 <div id="footer">
 Contact &lt;richard@pyweek.org&gt; with any enquiries.
-Site <A href="http://media.pyweek.org/static/conditions.html">conditions of use</A>.
+Site <A href="{{ STATIC_URL }}conditions.html">conditions of use</A>.
 Hosting thanks to <A href="http://tummy.com/">tummy.com</A>.<BR>
 Site developed in <A href="http://www.python.org/">Python</A>
 using <A href="http://www.djangoproject.com/">Django</A> and

pyweek/challenge/templates/challenge/ratings.html

 <dt>DNW</dt>
 <dd>The percentage of participants (users) who rated this game and couldn't get the game to run.</dd>
 <dt>DQ</dt>
-<dd>The percentage of total participants (users from finishing entries) who thought the entry broke the challenge <a href="http://media.pyweek.org/static/rules.html">rules</a>. </dd>
+<dd>The percentage of total participants (users from finishing entries) who thought the entry broke the challenge <a href="{{ STATIC_URL }}rules.html">rules</a>. </dd>
 </dl>
 
 

pyweek/challenge/templates/challenge/upload_award.html

               <input type="radio" name="award" value="{{award.id}}" />
             </td>
             <td>
-              <img src="http://media.pyweek.org/dl/{{award.content}}" /><br/>
+                <img src="{{ MEDIA_URL }}dl/{{award.content}}" /><br/>
               <strong>{{award.description}}</strong>
             </td>
           </tr>

pyweek/challenge/templates/challenge/user_display.html

   {% for entryaward in received_awards %}
     <div class="award">
       <a href="/a/{{entryaward.award.id}}">
-        <img src="http://media.pyweek.org/dl/{{entryaward.award.content}}">
+          <img src="{{ MEDIA_URL }}dl/{{entryaward.award.content}}">
       </a>
       <br/>
       <strong>{{entryaward.description|escape}}</strong>
   {% for award in given_awards %}
     <div class="award">
       <a href="/a/{{award.id}}">
-        <img src="http://media.pyweek.org/dl/{{award.content}}">
+          <img src="{{ MEDIA_URL }}dl/{{award.content}}">
       </a>
       <br/>
       <strong>{{award.description|escape}}</strong><br/>

pyweek/challenge/templates/registration/login.html

 <tr><td class="form-label"><label for="id_username">Username:</label></td><td>{{ form.username }}</td></tr>
 <tr><td class="form-label"><label for="id_password">Password:</label></td><td>{{ form.password }}</td></tr>
 <tr><td></td><td>
-<p class="form-help">By logging in you are agreeing to the PyWeek <a href="http://media.pyweek.org/static/conditions.html">conditions of use</a>.</p>
+        <p class="form-help">By logging in you are agreeing to the PyWeek <a href="{{ STATIC_URL }}conditions.html">conditions of use</a>.</p>
 <input type="submit" value="login">
 </td></tr>
 </table>

pyweek/challenge/templates/registration/register.html

 {% endif %}
 
 <p>By signing up to this challenge, you agree to its
-<a href="http://media.pyweek.org/static/conditions.html">conditions of use</a>.</p>
+<a href="{{ STATIC_URL }}conditions.html">conditions of use</a>.</p>
 
 <fieldset>
 <legend>Registration Form</legend>

pyweek/challenge/urls.py

     (r'^all_awards/$', 'view_all_awards'),
 )
 
-urlpatterns += patterns('django.views.static',
-    (r'^js/(?P<path>.*)$', 'serve',
-        {'document_root': '/home/pyweek/lib/pyweek/challenge/media/js'}),
-    (r'(^favicon\.ico$)', 'serve',
-        {'document_root': '/home/pyweek/lib/pyweek/challenge/media/'}),
-)
-

pyweek/settings.py

 
 DATABASES = {}
 
-# Absolute path to the directory that holds media.
-MEDIA_ROOT = '/home/pyweek/media/dl/'
+# Absolute path to the directory that holds uploaded files and its URL
+MEDIA_ROOT = ''     # must be set per deployment
+MEDIA_URL = '/media/'
 
-# URL that handles the media served from MEDIA_ROOT.
-MEDIA_URL = 'http://media.pyweek.org/dl/'
+# Absolute path to the directory that holds static files and its URL
+STATIC_ROOT = ''   # must be set per deployment
+STATIC_URL = '/static/'
+STATICFILES_DIRS = []
 
 # Path to the two RSS files generated by the challenge diary RSS generation
 # code
 TEMPLATE_CONTEXT_PROCESSORS = (
     "django.contrib.auth.context_processors.auth",
     "django.core.context_processors.debug",
+    "django.core.context_processors.static",
+    "django.core.context_processors.media",
     "django.contrib.messages.context_processors.messages",
 #    "django.core.context_processors.i18n",
     "pyweek.challenge.views.context.challenges",
 )
 
-STATIC_ROOT = '/home/pyweek/static/'
-STATIC_URL = 'http://pyweek.org/static/'
-
 INSTALLED_APPS = [
     'django.contrib.auth',
     'django.contrib.staticfiles',
 from django.conf.urls.defaults import *
 from django.contrib import admin
+from django.contrib.staticfiles.urls import staticfiles_urlpatterns
+from django.conf import settings
+
 admin.autodiscover()
 
 urlpatterns = patterns('',
      url(r'^admin/', include(admin.site.urls)),
      (r'', include('pyweek.challenge.urls')),
 )
+
+urlpatterns += staticfiles_urlpatterns()
+
+if settings.DEBUG:
+    urlpatterns += patterns('',
+        url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
+            'document_root': settings.MEDIA_ROOT,
+        }),
+   )
+
+Django==1.4.1
+Pillow==1.7.7
+django-wysiwyg==0.4.1
+simplejson==2.5.0
+stripogram==1.5
+wsgiref==0.1.2