mirror of
https://github.com/fergalmoran/dss.git
synced 2026-02-23 00:14:09 +00:00
Added featured option for mix
This commit is contained in:
@@ -84,7 +84,6 @@ class Mix(_BaseModel):
|
||||
def get_date_as_rfc822(self):
|
||||
return rfc822.formatdate(rfc822.mktime_tz(rfc822.parsedate_tz(self.upload_date.strftime("%a, %d %b %Y %H:%M:%S"))))
|
||||
|
||||
|
||||
@classmethod
|
||||
def get_for_username(cls, user):
|
||||
queryset = Mix.objects.filter(user__profile_slug__exact=user).order_by( '-id')
|
||||
@@ -93,25 +92,23 @@ class Mix(_BaseModel):
|
||||
@classmethod
|
||||
def get_listing(cls, listing_type, user=None):
|
||||
queryset = None
|
||||
candidates = Mix.objects\
|
||||
.filter(waveform_generated=True)\
|
||||
.filter(is_featured=True)
|
||||
|
||||
if listing_type == 'latest':
|
||||
queryset = Mix.objects.filter(waveform_generated=True).order_by( '-id')
|
||||
queryset = candidates.order_by( '-id')
|
||||
elif listing_type == 'toprated':
|
||||
queryset = Mix.objects.all()\
|
||||
.annotate(karma=Count('likes'))\
|
||||
.order_by('-karma')
|
||||
queryset = candidates.annotate(karma=Count('likes')).order_by('-karma')
|
||||
elif listing_type == 'mostactive':
|
||||
queryset = Mix.objects.all()\
|
||||
.annotate(karma=Count('comments'))\
|
||||
.order_by('-karma')
|
||||
queryset = candidates.filter(waveform_generated=True).annotate(karma=Count('comments')).order_by('-karma')
|
||||
elif listing_type == 'mostplayed':
|
||||
queryset = Mix.objects.all()\
|
||||
.annotate(karma=Count('plays'))\
|
||||
.order_by('-karma')
|
||||
queryset = queryset = candidates.annotate(karma=Count('plays')).order_by('-karma')
|
||||
elif listing_type == 'recommended':
|
||||
queryset = Mix.objects.all().order_by( '-id')
|
||||
queryset = queryset = candidates.order_by( '-id')
|
||||
elif listing_type == 'favourites':
|
||||
queryset = Mix.objects.filter(favourites__user=user).order_by('favourites__date')
|
||||
debug = queryset.query
|
||||
queryset = queryset = candidates.filter(favourites__user=user).order_by('favourites__date')
|
||||
|
||||
return queryset
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -47,6 +47,9 @@ class _BaseModel(models.Model):
|
||||
|
||||
def clean_image(self, image_field, sender):
|
||||
if self.__dict__[image_field] == "DONOTSEND":
|
||||
old_instance = sender.objects.get(pk=self.pk)
|
||||
if old_instance is not None:
|
||||
self.__dict__[image_field] = old_instance.__dict__[image_field]
|
||||
try:
|
||||
old_instance = sender.objects.get(pk=self.pk)
|
||||
if old_instance is not None:
|
||||
self.__dict__[image_field] = old_instance.__dict__[image_field]
|
||||
except Exception, ex:
|
||||
pass
|
||||
@@ -283,11 +283,11 @@ table .headerSortUp:after {
|
||||
-moz-opacity: 0.6;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
/*
|
||||
input[type="checkbox"] {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
*/
|
||||
.slideThree {
|
||||
width: 80px;
|
||||
height: 26px;
|
||||
|
||||
@@ -236,7 +236,7 @@ window.MixCreateView = DSSEditableView.extend({
|
||||
$('.fileupload', this.el).fileupload({
|
||||
'uploadtype':'image'
|
||||
});
|
||||
$('#mix-details', this.el).hide();
|
||||
//$('#mix-details', this.el).hide();
|
||||
$('.upload-hash', this.el).val(this.guid);
|
||||
} else {
|
||||
$('#div-upload-mix', this.el).hide();
|
||||
|
||||
@@ -72,9 +72,16 @@ window.DSSEditableView = Backbone.View.extend({
|
||||
},
|
||||
changed:function (evt) {
|
||||
var changed = evt.currentTarget;
|
||||
//$("#" + changed.id)
|
||||
if (!com.podnoms.utils.isEmpty(changed.id)) {
|
||||
var value = $("#" + changed.id).val();
|
||||
var obj = "{\"" + changed.id + "\":\"" + value.replace(/\n/g, '<br />') + "\"}";
|
||||
var value, obj;
|
||||
if ($(changed).is(':checkbox')) {
|
||||
value = $(changed).is(':checked');
|
||||
obj = "{\"" + changed.id + "\":" + value + "}";
|
||||
} else {
|
||||
value = $(changed).val();
|
||||
obj = "{\"" + changed.id + "\":\"" + value.replace(/\n/g, '<br />') + "\"}";
|
||||
}
|
||||
var objInst = JSON.parse(obj);
|
||||
this.model.set(objInst);
|
||||
}
|
||||
@@ -149,7 +156,7 @@ window.DSSEditableView = Backbone.View.extend({
|
||||
args[0].success();
|
||||
},
|
||||
error:function () {
|
||||
alert("Error saving release");
|
||||
args[0].error();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
<div class="row">
|
||||
<div class="control-group">
|
||||
<label class="control-label">Title</label>
|
||||
|
||||
<div class="controls">
|
||||
<input style="width: 98%" id="title" type="text" value="<%= item.title %>" placeholder="Brief title for your mix…">
|
||||
<input style="width: 98%" id="title" type="text" value="<%= item.title %>"
|
||||
placeholder="Brief title for your mix…">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -51,6 +53,12 @@
|
||||
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
|
||||
</div>
|
||||
</div>
|
||||
{% if user.is_staff %}
|
||||
<div>
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" id="is_featured" <% if (item.is_featured) { %>checked="checked"<% } %>">Is featured?</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
<li><a href="/mixes/favourites" id='favourites'>Favourites</a></li>
|
||||
{% endif %}
|
||||
|
||||
{% if user.is_staff %}
|
||||
<li class="pull-right"><a class="btn" href="/mix/upload" id='upload'>Upload</a></li>
|
||||
{% endif %}
|
||||
<li class="pull-right"><a class="btn" href="/mix/upload" id='upload'>Upload</a></li>
|
||||
</ul>
|
||||
<div id="mix-list-container"></div>
|
||||
Reference in New Issue
Block a user