Improved uuid slug for untitled snipt, and fix new flag.
parent
fc087b7a14
commit
3266bfd3f6
|
@ -494,6 +494,7 @@
|
||||||
success: function(model, response) {
|
success: function(model, response) {
|
||||||
$('button.save, button.save-and-close, button.delete, button.cancel',
|
$('button.save, button.save-and-close, button.delete, button.cancel',
|
||||||
window.site.$main_edit).removeAttr('disabled');
|
window.site.$main_edit).removeAttr('disabled');
|
||||||
|
that.model.set('new_from_js', false);
|
||||||
},
|
},
|
||||||
error: function(model, response) {
|
error: function(model, response) {
|
||||||
if (response.responseJSON) {
|
if (response.responseJSON) {
|
||||||
|
|
|
@ -12,7 +12,10 @@ def slugify_uniquely(value, model, slugfield="slug"):
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
if suffix:
|
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():
|
if not model.objects.filter(**{slugfield: potential}).count():
|
||||||
return potential
|
return potential
|
||||||
suffix = str(uuid.uuid4()).split('-')[0]
|
suffix = str(uuid.uuid4()).split('-')[0]
|
||||||
|
|
Loading…
Reference in New Issue