Improved uuid slug for untitled snipt, and fix new flag.

master
Nick Sergeant 2015-10-18 23:36:45 -04:00
parent fc087b7a14
commit 3266bfd3f6
2 changed files with 5 additions and 1 deletions

View File

@ -494,6 +494,7 @@
success: function(model, response) {
$('button.save, button.save-and-close, button.delete, button.cancel',
window.site.$main_edit).removeAttr('disabled');
that.model.set('new_from_js', false);
},
error: function(model, response) {
if (response.responseJSON) {

View File

@ -12,7 +12,10 @@ def slugify_uniquely(value, model, slugfield="slug"):
while True:
if suffix:
potential = "-".join([base, str(suffix)])
if value:
potential = "-".join([base, str(suffix)])
else:
potential = str(suffix)
if not model.objects.filter(**{slugfield: potential}).count():
return potential
suffix = str(uuid.uuid4()).split('-')[0]