mirror of
https://github.com/fergalmoran/dss.git
synced 2026-01-06 08:54:12 +00:00
Edit releases
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from django.contrib.sites.models import Site
|
||||
from django.db.models.signals import post_save
|
||||
from django.db.models.signals import pre_save
|
||||
from django.dispatch import Signal, receiver
|
||||
import os
|
||||
import rfc822
|
||||
@@ -51,6 +52,7 @@ class Mix(_BaseModel):
|
||||
if os.path.isfile(self.get_waveform_path()):
|
||||
self.waveform_generated = True
|
||||
|
||||
self.clean_image('mix_image', Mix)
|
||||
super(Mix, self).save(force_insert, force_update, using)
|
||||
|
||||
def get_absolute_url(self):
|
||||
|
||||
@@ -32,6 +32,7 @@ class Release(_BaseModel):
|
||||
return self.release_title
|
||||
|
||||
def save(self, force_insert=False, force_update=False, using=None):
|
||||
self.clean_image('release_image', Release)
|
||||
super(Release, self).save(force_insert, force_update, using)
|
||||
|
||||
def get_absolute_url(self):
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import logging
|
||||
from django.db import models
|
||||
from django.db.models import get_model
|
||||
from django.utils import simplejson
|
||||
import os
|
||||
from core.utils import url
|
||||
@@ -41,4 +40,13 @@ class _BaseModel(models.Model):
|
||||
for field in field_list:
|
||||
if field.endswith("name") or field.endswith("description"):
|
||||
return field
|
||||
return "description"
|
||||
return "description"
|
||||
|
||||
def base_pre_save(self, sender, instance, created, **kwargs):
|
||||
pass
|
||||
|
||||
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]
|
||||
@@ -1,8 +1,10 @@
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.db.models.signals import pre_save
|
||||
from django.dispatch import receiver, Signal
|
||||
from django.db.models import signals
|
||||
from django.contrib.auth.management import create_superuser
|
||||
from django.contrib.auth import models as auth_app
|
||||
from spa.models import _BaseModel, Release
|
||||
from spa.models.Mix import Mix
|
||||
|
||||
waveform_generated = Signal()
|
||||
@@ -18,6 +20,17 @@ def waveform_generated_callback(sender, **kwargs):
|
||||
except ObjectDoesNotExist:
|
||||
pass
|
||||
waveform_generated.connect(waveform_generated_callback)
|
||||
|
||||
"""
|
||||
def handle_image_updating(sender, field, instance, **kwargs):
|
||||
#Don't over
|
||||
if instance.id:
|
||||
if instance[field] == 'DONOTSEND':
|
||||
old_item = Mix.objects.get(pk=instance.id)
|
||||
instance[field] = old_item[field]
|
||||
instance.post.save()
|
||||
"""
|
||||
|
||||
"""
|
||||
signals.post_syncdb.disconnect(
|
||||
create_superuser,
|
||||
|
||||
@@ -11,6 +11,13 @@ window.Mix = DSSModel.extend({
|
||||
schema:{
|
||||
title:'Text',
|
||||
description:'Text'
|
||||
},
|
||||
isValid:function () {
|
||||
this.errors = {};
|
||||
if (com.podnoms.utils.isEmpty(this.get('title'))) {
|
||||
return this.addError('title', 'Please enter a title');
|
||||
}
|
||||
return "";
|
||||
}
|
||||
});
|
||||
window.MixCollection = TastypieCollection.extend({
|
||||
|
||||
@@ -28,13 +28,15 @@ window.MixListItemView = Backbone.View.extend({
|
||||
var id = this.model.get("id");
|
||||
this.setLikeButton(id, this.model.get('liked'));
|
||||
this.setFavouriteButton(id, this.model.get('favourited'));
|
||||
$('#mix-link-' + id, this.el).popover({
|
||||
animation: true,
|
||||
placement: 'bottom',
|
||||
trigger: 'hover',
|
||||
html: 'true',
|
||||
delay: { show: 500, hide: 500 }
|
||||
});
|
||||
/*
|
||||
$('#mix-link-' + id, this.el).popover({
|
||||
animation: true,
|
||||
placement: 'bottom',
|
||||
trigger: 'hover',
|
||||
html: 'true',
|
||||
delay: { show: 500, hide: 500 }
|
||||
});
|
||||
*/
|
||||
return this;
|
||||
},
|
||||
setLikeButton:function (id, liked) {
|
||||
@@ -244,41 +246,43 @@ window.MixCreateView = DSSEditableView.extend({
|
||||
var parent = this;
|
||||
this.model.set('upload-hash', this.guid);
|
||||
this.model.set('upload-extension', $('#upload-extension', this.el).val());
|
||||
this.model.save(
|
||||
null, {
|
||||
success:function () {
|
||||
if (parent.sendImage) {
|
||||
$.ajaxFileUpload({
|
||||
url:'/ajax/upload_image/' + model.get('id') + '/',
|
||||
secureuri:false,
|
||||
fileElementId:'mix_image',
|
||||
success:function (data, status) {
|
||||
if (typeof(data.error) != 'undefined') {
|
||||
if (data.error != '') {
|
||||
alert(data.error);
|
||||
} else {
|
||||
alert(data.msg);
|
||||
}
|
||||
if (!parent.sendImage)
|
||||
this.model.set('mix_image', 'DONOTSEND');
|
||||
|
||||
this._saveChanges({
|
||||
success:function () {
|
||||
if (parent.sendImage) {
|
||||
$.ajaxFileUpload({
|
||||
url:'/ajax/upload_image/' + model.get('id') + '/',
|
||||
secureuri:false,
|
||||
fileElementId:'mix_image',
|
||||
success:function (data, status) {
|
||||
if (typeof(data.error) != 'undefined') {
|
||||
if (data.error != '') {
|
||||
alert(data.error);
|
||||
} else {
|
||||
$('#mix-details', this.el).hide();
|
||||
parent.state++;
|
||||
parent.checkRedirect();
|
||||
alert(data.msg);
|
||||
}
|
||||
},
|
||||
error:function (data, status, e) {
|
||||
alert(e);
|
||||
} else {
|
||||
$('#mix-details', this.el).hide();
|
||||
parent.state++;
|
||||
parent.checkRedirect();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$('#mix-details', this.el).hide();
|
||||
parent.state++;
|
||||
parent.checkRedirect();
|
||||
}
|
||||
},
|
||||
error:function () {
|
||||
com.podnoms.utils.showAlert("Error", "Something went wrong", "alert-info", false);
|
||||
},
|
||||
error:function (data, status, e) {
|
||||
alert(e);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$('#mix-details', this.el).hide();
|
||||
parent.state++;
|
||||
parent.checkRedirect();
|
||||
}
|
||||
});
|
||||
},
|
||||
error:function () {
|
||||
com.podnoms.utils.showAlert("Error", "Something went wrong", "alert-info", false);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
},
|
||||
imageChanged:function (evt) {
|
||||
|
||||
@@ -80,6 +80,7 @@ var ReleaseView = Backbone.View.extend({
|
||||
var ReleaseCreateView = DSSEditableView.extend({
|
||||
events:{
|
||||
"click #save-changes":"saveChanges",
|
||||
"change #release_image":"imageChanged",
|
||||
"change input":"changed",
|
||||
"change textarea":"changed",
|
||||
"change select":"changeSelect"
|
||||
@@ -88,6 +89,7 @@ var ReleaseCreateView = DSSEditableView.extend({
|
||||
this.render();
|
||||
},
|
||||
render:function () {
|
||||
this.sendImage = false;
|
||||
$(this.el).html(this.template({"item":this.model.toJSON()}));
|
||||
this._bakeForm(this.el, 'label');
|
||||
},
|
||||
@@ -99,7 +101,6 @@ var ReleaseCreateView = DSSEditableView.extend({
|
||||
this.model.set('release_description', $('#release-description', this.el).html());
|
||||
this.model.set('release_date', $('#release_date', this.el).val());
|
||||
this.model.set('embed_code', $('#embed_code', this.el).val());
|
||||
|
||||
this._saveChanges({
|
||||
success:function () {
|
||||
com.podnoms.utils.showAlert("Success", "Release successfully added", "alert-info", true);
|
||||
@@ -107,5 +108,8 @@ var ReleaseCreateView = DSSEditableView.extend({
|
||||
}
|
||||
});
|
||||
return false;
|
||||
},
|
||||
imageChanged:function (evt) {
|
||||
this.sendImage = true;
|
||||
}
|
||||
});
|
||||
@@ -14,25 +14,26 @@
|
||||
<input type="hidden" id="upload-extension">
|
||||
<legend>Mix details</legend>
|
||||
<div class="row">
|
||||
<div class="span6">
|
||||
<div class="control-group">
|
||||
<label class="control-label">Title</label>
|
||||
<div class="controls">
|
||||
<input id="title" type="text" value="<%= item.title %>" placeholder="Brief title for your mix…">
|
||||
</div>
|
||||
<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…">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span9">
|
||||
<div class="control-group">
|
||||
<label class="control-label">Description</label>
|
||||
|
||||
<div class="controls">
|
||||
<textarea id="description" rows="10" placeholder="Tracklist would be nice…"><%= item.description %></textarea>
|
||||
<textarea style="width: 98%" id="description" rows="12" placeholder="Tracklist would be nice…"><%= item.description %></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="span6">
|
||||
<div class="span3">
|
||||
<div class="fileupload fileupload-new" data-provides="fileupload">
|
||||
<div class="fileupload-new thumbnail" style="width: 200px; height: 150px;">
|
||||
<img src="<%= item.mix_image %>" />
|
||||
<img src="<%= item.mix_image %>"/>
|
||||
</div>
|
||||
<div class="fileupload-preview fileupload-exists thumbnail"
|
||||
style="max-width: 200px; max-height: 150px; line-height: 20px;">
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
<label class="control-label">Artist</label>
|
||||
|
||||
<div class="controls">
|
||||
<input id="release_artist" type="text" placeholder="Who dunnit…" value="<%= item.release_artist %>">
|
||||
<input id="release_artist" type="text" placeholder="Who dunnit…"
|
||||
value="<%= item.release_artist %>">
|
||||
<span class="help-inline" id="error-release_artist"></span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -26,8 +27,10 @@
|
||||
<div class="span6">
|
||||
<div class="control-group" id="group-release_title">
|
||||
<label class="control-label">Title</label>
|
||||
|
||||
<div class="controls">
|
||||
<input id="release_title" type="text" placeholder="What they dun…" value="<%= item.release_title %>">
|
||||
<input id="release_title" type="text" placeholder="What they dun…"
|
||||
value="<%= item.release_title %>">
|
||||
<span class="help-inline" id="error-release_title"></span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -35,18 +38,41 @@
|
||||
<label class="control-label">Release date</label>
|
||||
|
||||
<div class="controls">
|
||||
<input id="release_date" class="datepicker" type="text">
|
||||
<input id="release_date" class="datepicker" type="text" value="<%= item.release_date %>">
|
||||
<span class="help-inline" id="error-release_date"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="control-group">
|
||||
<label class="control-label">Embed Code</label>
|
||||
|
||||
<div class="controls">
|
||||
<textarea style="width:98%" id="embed_code" rows="3"/>
|
||||
<div class="span8">
|
||||
<div class="control-group">
|
||||
<label class="control-label">Embed Code</label>
|
||||
<div class="controls">
|
||||
<textarea style="width:98%" id="embed_code" rows="5"><%= item.embed_code %></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="span4 pull-right">
|
||||
<div class="fileupload fileupload-new" data-provides="fileupload">
|
||||
<div class="fileupload-new thumbnail" style="width: 200px; height: 150px;">
|
||||
<img src="<%= item.release_image %>" />
|
||||
</div>
|
||||
<div class="fileupload-preview fileupload-exists thumbnail"
|
||||
style="max-width: 200px; max-height: 150px; line-height: 20px;">
|
||||
</div>
|
||||
<div>
|
||||
<span class="btn btn-file">
|
||||
<span class="fileupload-new">
|
||||
Select image
|
||||
</span>
|
||||
<span class="fileupload-exists">
|
||||
Change
|
||||
</span>
|
||||
<input id="release_image" type="file" size="45" name="release_image" class="input">
|
||||
</span>
|
||||
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -55,7 +81,7 @@
|
||||
<label class="control-label">Description</label>
|
||||
|
||||
<div class="controls">
|
||||
<textarea style="width:100%" class="tinymce" id="release-description" rows="10"/>
|
||||
<textarea style="width:100%" class="tinymce" id="release-description" rows="10"><%= item.description %></textarea>
|
||||
<span class="help-inline" id="error-release_description"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user