Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

admin playlist preview and file upload limits

  • Loading branch information...
commit 4098afe506067d21b8eb57af593beda85ed3c601 1 parent 7c2c1ee
Barbara Shaurette authored
View
6 feeds.py
@@ -6,9 +6,9 @@
from fivesongs.playlist.models import Playlist
class LatestPlaylists(Feed):
- title = ""
- link = ""
- description = ""
+ title = "Five Songs Daily"
+ link = "http://www.fivesongsdaily.com/"
+ description = "Latest playlists on Five Songs Daily"
def items(self):
todaysdate = datetime.datetime.now().strftime("%Y-%m-%d")
View
16 playlist/templates/playlist_save.html
@@ -14,11 +14,15 @@
<td>{{ form_song.artist.label }} {{ form_song.artist }}</td>
<td>{{ form_song.title.label }} {{ form_song.title }}</td>
<td>{{ form_song.filepath.label }} {{ form_song.filepath }}</td>
- <td><input type="submit" value="Add a song" /><br /></td>
+ <td>
+ <input type="submit" value="Add a song" /><br />
+ (Limit: 5 MB)<br />
+ </td>
</form>
</tr>
</table>
<div class="right" style="color: red;">
+ {% if upload_message %}{{ upload_message }}{% endif %}
{% if form_song.non_field_errors %}<ul class="errorlist">{{ form_song.non_field_errors.as_ul }}</ul>{% endif %}
{% if form_song.field.errors %}<ul class="errorlist">{{ form_song.field.errors.as_ul }}</ul>{% endif %}
</div>
@@ -81,15 +85,7 @@
{% block content_smallcol %}
- <p>Bear with me - there are still some kinks to work out here, so if you come across any egregious errors, just email, DM, or send me a message through the <a href="/contact/">contact form</a>.</p>
-
- <p>I don't have a progress bar for the file uploads yet, so if you add a song and it seems to be taking a while, please be nice to the server and don't mash the reload button over and over - just be patient, it'll get there.</p>
-
- <p>When you start adding songs, dropdowns will appear below that will allow you to add them to a playlist. You need to have at least five songs to create a playlist.</p>
-
- <p>New playlists will be listed under "Your playlists pending review". Once I give it a date, look for it under "Your queued playlists".</p>
-
- <p>I'm open to suggestions on how this interface should work - this is just the best solution I've come up with so far. <a href="/contact/">Let me know</a> if you've got better ideas.</p>
+ <p>(upload requirements)</p>
{% endblock %}
View
15 playlist/urls.py
@@ -5,13 +5,16 @@
from fivesongs.playlist import views
urlpatterns = patterns('',
- url(r'^id/(?P<id>\w+)/*$', views.show_id, name='playlist_byid'),
- url(r'^all/*$', views.show_all, name='playlist_all'),
+ url(r'^preview/(?P<id>\w+)/*$', views.preview_id, name='playlist_previewbyid'),
- url(r'^song/add/*$', views.user_song_upload, name='playlist_song_upload'),
- url(r'^upload/*$', views.user_playlist, name='playlist_save'),
+ url(r'^id/(?P<id>\w+)/*$', views.show_id, name='playlist_byid'),
+ url(r'^all/*$', views.show_all, name='playlist_all'),
- url(r'^(?P<id>\w+)/*$', views.show_id, name='playlist_byid'),
- url(r'^$', views.show_home, name='playlist_home'),
+ url(r'^song/add/*$', views.user_song_upload, name='playlist_song_upload'),
+ url(r'^upload/(?P<message>.*?)/*$', views.user_playlist, name='playlist_save'),
+ url(r'^upload/*$', views.user_playlist, name='playlist_save'),
+
+ url(r'^(?P<id>\w+)/*$', views.show_id, name='playlist_byid'),
+ url(r'^$', views.show_home, name='playlist_home'),
)
View
36 playlist/views.py
@@ -111,21 +111,44 @@ def show_id(request, id):
return render_to_response(template_name, context, context_instance=RequestContext(request))
@login_required
+def preview_id(request, id):
+ template_name = 'preview.html'
+ context = {}
+
+ if request.user.is_superuser:
+ try:
+ playlist = Playlist.objects.get(pk=id, active=True)
+ except ObjectDoesNotExist:
+ playlist = None
+ return HttpResponseRedirect('/')
+ else:
+ playlist = None
+ return HttpResponseRedirect('/')
+
+ context['playlist'] = playlist
+ return render_to_response(template_name, context, context_instance=RequestContext(request))
+
+@login_required
def user_song_upload(request):
template_name = 'song_add.html'
context = {}
form_class = SongForm
if request.method == 'POST':
form = form_class(request.POST, request.FILES)
- if form.is_valid():
+ logging.debug('******* file size ***********')
+ logging.debug(request.FILES['filepath'].size)
+ if request.FILES['filepath'].size < 5457045 and form.is_valid():
song = form.save(commit=False)
song.active = True
song.user = request.user
song.save()
- return HttpResponseRedirect('/playlist/upload/')
+ return HttpResponseRedirect('/playlist/upload/success/')
+ else:
+ logging.debug('********* file too large ***************')
+ return HttpResponseRedirect('/playlist/upload/error/')
@login_required
-def user_playlist(request):
+def user_playlist(request, message):
template_name = 'playlist_save.html'
context = {}
form_class = PlaylistForm
@@ -173,5 +196,12 @@ def user_playlist(request):
context['form'] = form
context['form_song'] = SongForm()
+ if message == 'error':
+ context['upload_message'] = 'Sorry, that file was too large.'
+ if message == 'success':
+ context['upload_message'] = 'Your file was uploaded successfully.'
+ logging.debug('*************** message **************')
+ logging.debug(message)
+
return render_to_response(template_name, context, context_instance=RequestContext(request))
View
2  templates/header.html
@@ -9,7 +9,7 @@
<a href="/accounts/logout/">log out</a>
</div>
<div class="left">
- <a href="http://twitter.com/" title="follow on twitter" target="new"><img src="/site_media/images/fivesongs_icon_twitter.jpg"></a>
+ <a href="http://twitter.com/fivesongsdaily" title="follow fivesongsdaily on twitter" target="new"><img src="/site_media/images/fivesongs_icon_twitter.jpg"></a>
<a href="/feeds/all/" title="subscribe to the rss feed"><img src="/site_media/images/fivesongs_icon_rss.jpg"></a>
</div>
View
5 urls.py
@@ -11,6 +11,7 @@
}
urlpatterns = patterns('',
+ (r'^admin/r/10/(?P<id>\w+)/*$', 'fivesongs.playlist.views.preview_id'),
(r'^admin/(.*)', admin.site.root),
(r'^comments/', include('django.contrib.comments.urls')),
@@ -18,14 +19,12 @@
(r'^accounts/login/$', 'django.contrib.auth.views.login', {'template_name': 'accounts/login/login.html'}),
(r'^accounts/logout/$', 'django.contrib.auth.views.logout'),
- (r'^ajax/', include('fivesongs.ajax.urls')),
-
(r'^password_reset/$', 'django.contrib.auth.views.password_reset'),
(r'^password_reset/done/$', 'django.contrib.auth.views.password_reset_done'),
(r'^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm'),
(r'^reset/done/$', 'django.contrib.auth.views.password_reset_complete'),
- (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/fivesongs/site_media/'}),
+ (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/Users/barbara/Code/fivesongs/site_media/'}),
(r'^profile/', include('fivesongs.profiles.urls')),
(r'^playlist/', include('fivesongs.playlist.urls')),
(r'^messages/', include('fivesongs.message.urls')),
Please sign in to comment.
Something went wrong with that request. Please try again.