Permalink
Browse files

user uploads and ajax comments

  • Loading branch information...
Barbara Shaurette Barbara Shaurette
Barbara Shaurette authored and Barbara Shaurette committed Jun 1, 2009
1 parent 09b9ddb commit 7c2c1ee49191d5483dcf400be7471d9b1d145f5b
View
@@ -6,9 +6,9 @@
from fivesongs.playlist.models import Playlist
class LatestPlaylists(Feed):
- title = "Five Songs Daily"
- link = "http://www.fivesongsdaily.com/"
- description = "Latest playlists on Five Songs Daily"
+ title = ""
+ link = ""
+ description = ""
def items(self):
todaysdate = datetime.datetime.now().strftime("%Y-%m-%d")
View
No changes.
View
@@ -0,0 +1,6 @@
+from fivesongs.message.models import Message
+
+from django.contrib import admin
+
+admin.site.register(Message)
+
View
@@ -0,0 +1,18 @@
+import logging
+
+from django.db import models
+from django.http import Http404
+from django.template.loader import render_to_string
+from django.utils.translation import ugettext_lazy as _
+
+class Message(models.Model):
+ message = models.TextField()
+ active = models.BooleanField(default=True)
+ created_at = models.DateTimeField(auto_now_add=True)
+
+ def __str__(self):
+ return u"%s" %self.message
+
+ class Meta:
+ ordering = ['-created_at']
+
@@ -0,0 +1,17 @@
+{% extends "base.html" %}
+
+{% block page_title %}
+ : Messages
+{% endblock %}
+
+{% block content_bigcol %}
+
+ {% if messages %}
+ {% for message in messages %}
+ <p><b>{{ message.created_at|date:"M d, Y" }}</b></p>
+ <div class="post_body">{% autoescape off %}{{ message.message|linebreaks }}{% endautoescape %}</div>
+ <hr>
+ {% endfor %}
+ {% endif %}
+
+{% endblock %}
View
@@ -0,0 +1,8 @@
+from django.conf.urls.defaults import *
+
+from fivesongs.message import views
+
+urlpatterns = patterns('',
+ url(r'^$', views.show_all, name='messages_all'),
+)
+
View
@@ -0,0 +1,28 @@
+import logging
+import datetime
+from time import strftime
+
+from django.conf import settings
+from django.contrib.auth import authenticate
+from django.contrib.auth.decorators import login_required
+from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
+from django.http import Http404, HttpResponse, HttpResponseRedirect
+from django.shortcuts import render_to_response
+from django.template import RequestContext
+from django.template.loader import render_to_string
+
+from fivesongs.message.models import Message
+
+@login_required
+def show_all(request):
+ template_name = 'messages.html'
+ context = {}
+
+ try:
+ messages = Message.objects.filter(active=True).order_by('-created_at')[:5]
+ except ObjectDoesNotExist:
+ messages = None
+ context['messages'] = messages
+
+ return render_to_response(template_name, context, context_instance=RequestContext(request))
+
View
@@ -2,7 +2,15 @@
from django.contrib import admin
-admin.site.register(Playlist)
-admin.site.register(Song)
+class SongAdmin(admin.ModelAdmin):
+ list_display = ('title', 'artist', 'user', 'active',)
+ list_filter = ('artist',)
+
+class PlaylistAdmin(admin.ModelAdmin):
+ list_display = ('play_date', 'user', 'active', 'song1', 'song2', 'song3', 'song4', 'song5',)
+ list_filter = ('active', 'user',)
+
+admin.site.register(Playlist, PlaylistAdmin)
+admin.site.register(Song, SongAdmin)
View
@@ -1,8 +1,11 @@
+import logging
+
from django import forms
from django.forms import ModelForm
from django.utils.translation import ugettext_lazy as _
+from django.contrib.auth.models import User
-from fivesongs.playlist.models import Playlist, Comment
+from fivesongs.playlist.models import Song, Playlist, Comment
class CommentForm(ModelForm):
fullname = forms.CharField(label='Your Name', error_messages={'required': 'Please enter your name.'})
@@ -13,3 +16,27 @@ class CommentForm(ModelForm):
class Meta:
model = Comment
+class SongForm(ModelForm):
+ artist = forms.CharField(label='Artist:', widget=forms.TextInput(attrs={' class': 'input_short' }), required=True)
+ title = forms.CharField(label='Title:', widget=forms.TextInput(attrs={' class': 'input_short' }), required=True)
+ filepath = forms.FileField(label='File:', required=True)
+
+ class Meta:
+ model = Song
+ exclude = ('user',)
+
+class PlaylistForm(ModelForm):
+ def clean(self):
+ data = {}
+ for k,v in self.cleaned_data.iteritems():
+ if type(v) is str or type(v) is unicode:
+ data[k] = v
+ logging.debug('CLEANED DATA ================ %s' %data)
+ # if self.cleaned_data['song1'] == (self.cleaned_data['song2'] or self.cleaned_data['song3'] or self.cleaned_data['song4'] or self.cleaned_data['song5']):
+ # raise forms.ValidationError(_(u'You have selected the same song more than once - try again.'))
+ return self.cleaned_data
+
+ class Meta:
+ model = Playlist
+ exclude = ('user',)
+
View
@@ -9,10 +9,11 @@
class Song(models.Model):
"""
"""
+ user = models.ForeignKey(User, editable=True)
artist = models.CharField(max_length=255)
title = models.CharField(max_length=255)
album = models.CharField(max_length=255, blank=True)
- filepath = models.CharField(max_length=255)
+ filepath = models.FileField('file upload', upload_to='mp3/', blank=True)
active = models.BooleanField(default=True)
created_at = models.DateTimeField(auto_now_add=True)
@@ -21,10 +22,12 @@ def __str__(self):
class Meta:
ordering = ['-created_at']
+ unique_together = ("artist", "title",)
class Playlist(models.Model):
"""
"""
+ user = models.ForeignKey(User, editable=True)
play_date = models.DateField()
song1 = models.ForeignKey(Song, related_name="song1")
song2 = models.ForeignKey(Song, related_name="song2")
@@ -6,6 +6,13 @@
{% block content_bigcol %}
{% include "archive_list.html" %}
+
+ <div class="pagination" align="center">
+ {% for page in page_range %}
+ <a href="/playlist/all/?page={{ page }}">{{ page }}</a>
+ {% endfor %}
+ </div>
+
{% endblock %}
@@ -5,8 +5,8 @@
{% for playlist in all_playlists %}
<div class="archive_list">
<p>
- <a style="text-decoration: none; font-weight: bold;" href="/id/{{ playlist.id }}">Playlist for {{ playlist.play_date|date:"M d, Y" }}</a>
- <a style="text-decoration: none; font-style: italic;" href="/id/{{ playlist.id }}">{% get_comment_count for playlist as comment_count %} ({{ comment_count }} comments)</a><br />
+ <a class="playlist_date" href="/id/{{ playlist.id }}">Playlist for {{ playlist.play_date|date:"M d, Y" }}</a>
+ <a class="comment_count" href="/id/{{ playlist.id }}">{% get_comment_count for playlist as comment_count %} ({{ comment_count }} comments)</a><br />
{{ playlist.song1 }}<br />
{{ playlist.song2 }}<br />
{{ playlist.song3 }}<br />
@@ -15,7 +15,6 @@
</p>
</div>
{% endfor %}
- <div class="more"><a href="/playlist/all/">all the rest &rsaquo</a></div>
{% else %}
No playlists yet.<br />
{% endif %}
@@ -4,11 +4,17 @@
: All Entries
{% endblock %}
+{% block page_js %}
+ <script language="javascript" src="/site_media/js/jquery-1.3.2.js"></script>
+ <script language="javascript" src="/site_media/js/postComment.js"></script>
+{% endblock %}
+
{% block content_bigcol %}
{% include "main_player.html" %}
{% endblock %}
{% block content_smallcol %}
{% include "archive_list.html" %}
+ <div class="more"><a href="/playlist/all/">all the rest &rsaquo</a></div>
{% endblock %}
@@ -1,93 +1,31 @@
{% if playlist %}
-
- <div class="bigplaylist">
+
+ <div align="center">
+ <div style="margin-bottom: 20px; width: 450px;">
- <p align="center"><b>Today's Playlist ({{ playlist.play_date|date:"M d Y" }}) : </b></p>
+ <p><b>Today's Playlist ({{ playlist.play_date|date:"M d Y" }}) : </b></p>
- <table align="center">
-
- <tr valign="top">
- <td>{{ playlist.song1 }} {% if playlist.song1.album %}({{ playlist.song1.album }}){% endif %}</td>
- <td>
- <object type="application/x-shockwave-flash" data="/site_media/flash/musicplayer.swf?&song_url={{ playlist.song1.filepath }}&" width="17" height="17">
- <param name="movie" value="/site_media/flash/musicplayer.swf?&song_url={{ playlist.song1.filepath }}&" />
- <img src="noflash.gif" width="17" height="17" alt="" />
- </object>
- </td>
- <td><a href="{{ playlist.song1.filepath }}" title="right click to download">mp3</a></td>
- </tr>
-
- <tr valign="top">
- <td>{{ playlist.song2 }} {% if playlist.song2.album %}({{ playlist.song2.album }}){% endif %}</td>
- <td>
- <object type="application/x-shockwave-flash" data="/site_media/flash/musicplayer.swf?&song_url={{ playlist.song2.filepath }}&" width="17" height="17">
- <param name="movie" value="/site_media/flash/musicplayer.swf?&song_url={{ playlist.song2.filepath }}&" />
- <img src="noflash.gif" width="17" height="17" alt="" />
- </object>
- </td>
- <td><a href="{{ playlist.song2.filepath }}" title="right click to download">mp3</a></td>
- </tr>
-
- <tr valign="top">
- <td>{{ playlist.song3 }} {% if playlist.song3.album %}({{ playlist.song3.album }}){% endif %}</td>
- <td>
- <object type="application/x-shockwave-flash" data="/site_media/flash/musicplayer.swf?&song_url={{ playlist.song3.filepath }}&" width="17" height="17">
- <param name="movie" value="/site_media/flash/musicplayer.swf?&song_url={{ playlist.song3.filepath }}&" />
- <img src="noflash.gif" width="17" height="17" alt="" />
- </object>
- </td>
- <td><a href="{{ playlist.song3.filepath }}" title="right click to download">mp3</a></td>
- </tr>
-
- <tr valign="top">
- <td>{{ playlist.song4 }} {% if playlist.song4.album %}({{ playlist.song4.album }}){% endif %}</td>
- <td>
- <object type="application/x-shockwave-flash" data="/site_media/flash/musicplayer.swf?&song_url={{ playlist.song4.filepath }}&" width="17" height="17">
- <param name="movie" value="/site_media/flash/musicplayer.swf?&song_url={{ playlist.song4.filepath }}&" />
- <img src="noflash.gif" width="17" height="17" alt="" />
- </object>
- </td>
- <td><a href="{{ playlist.song4.filepath }}" title="right click to download">mp3</a></td>
- </tr>
-
- <tr valign="top">
- <td>{{ playlist.song5 }} {% if playlist.song5.album %}({{ playlist.song5.album }}){% endif %}</td>
- <td>
- <object type="application/x-shockwave-flash" data="/site_media/flash/musicplayer.swf?&song_url={{ playlist.song5.filepath }}&" width="17" height="17">
- <param name="movie" value="/site_media/flash/musicplayer.swf?&song_url={{ playlist.song5.filepath }}&" />
- <img src="noflash.gif" width="17" height="17" alt="" />
- </object>
- </td>
- <td><a href="{{ playlist.song5.filepath }}" title="right click to download">mp3</a></td>
- </tr>
+ <div style="float: left">
+ <object type="application/x-shockwave-flash" data="/site_media/flash/player_mp3_multi.swf" width="400" height="100" align="center">
+ <param name="movie" value="/site_media/flash/player_mp3_multi.swf" />
+ <param name="FlashVars" value="mp3=/site_media/{{ playlist.song1.filepath }}|/site_media/{{ playlist.song2.filepath }}|/site_media/{{ playlist.song3.filepath }}|/site_media/{{ playlist.song4.filepath }}|/site_media/{{ playlist.song5.filepath }}&amp;title={{ playlist.song1 }}|{{ playlist.song2 }}|{{ playlist.song3 }}|{{ playlist.song4 }}|{{ playlist.song5 }}&amp;width=400&amp;height=100" />
+ </object>
+ </div>
- </table>
+ <div style="float: left; width: 50px;">
+ <a href="/site_media/{{ playlist.song1.filepath }}" title="right click to download">mp3</a><br />
+ <a href="/site_media/{{ playlist.song2.filepath }}" title="right click to download">mp3</a><br />
+ <a href="/site_media/{{ playlist.song3.filepath }}" title="right click to download">mp3</a><br />
+ <a href="/site_media/{{ playlist.song4.filepath }}" title="right click to download">mp3</a><br />
+ <a href="/site_media/{{ playlist.song5.filepath }}" title="right click to download">mp3</a><br />
</div>
+ <div class="clear"></div>
- {% load comments %}
+ <p>Posted by: <a href="/profile/{{ playlist.user }}/">{{ playlist.user }}</a></p>
- <div class="comment_form">
- {% get_comment_form for playlist as form %}
- <form action="{% comment_form_target %}" method="POST">
- {{ form.comment }}
- <p style="display: none;">{{ form.honeypot }}</p>
- {{ form.content_type }}
- {{ form.object_pk }}
- {{ form.timestamp }}
- {{ form.security_hash }}
- <p><input type="submit" value="Leave a comment" id="id_submit" /></p>
- </form>
- <!-- render_comment_form for playlist -->
- </div>
+ </div></div>
- {% get_comment_list for playlist as cmt_list %}
- {% for comment in cmt_list %}
- <div class="comment">
- <a href="/profile/{{ comment.user.username }}/">{{ comment.user.username }}</a><br />
- {{ comment.submit_date|date:"M d Y" }}
- {{ comment.comment|linebreaks }}
- </div>
- {% endfor %}
+ {% include "playlist_comments.html" %}
{% else %}
No playlist today.<br />
@@ -1,6 +1,6 @@
-Date: {{ date }}
+New playlist uploaded by: {{ user }}
+
+Approve or delete here: http://{{ site }}/admin/playlist/playlist/?user__id__exact={{ user_id }}&active__exact=0
-Message: {{ message }}
-Approve or delete here: http://{{ site }}/admin/entry/post/{{ post_id }}/
Oops, something went wrong.

0 comments on commit 7c2c1ee

Please sign in to comment.