Commit e237b2ac by benjaoming

Creating a proper WikiSlug javascript generator from the django urlify

parent 95d8651b
...@@ -99,7 +99,6 @@ class AttachmentReplaceView(ArticleMixin, FormView): ...@@ -99,7 +99,6 @@ class AttachmentReplaceView(ArticleMixin, FormView):
return redirect(wiki_settings.LOGIN_URL) return redirect(wiki_settings.LOGIN_URL)
return super(AttachmentReplaceView, self).dispatch(request, article, *args, **kwargs) return super(AttachmentReplaceView, self).dispatch(request, article, *args, **kwargs)
@transaction.commit_manually
def form_valid(self, form): def form_valid(self, form):
try: try:
...@@ -112,19 +111,14 @@ class AttachmentReplaceView(ArticleMixin, FormView): ...@@ -112,19 +111,14 @@ class AttachmentReplaceView(ArticleMixin, FormView):
self.attachment.save() self.attachment.save()
messages.success(self.request, _(u'%s uploaded and replaces old attachment.') % attachment_revision.get_filename()) messages.success(self.request, _(u'%s uploaded and replaces old attachment.') % attachment_revision.get_filename())
except models.IllegalFileExtension, e: except models.IllegalFileExtension, e:
transaction.rollback()
messages.error(self.request, _(u'Your file could not be saved: %s') % e) messages.error(self.request, _(u'Your file could not be saved: %s') % e)
transaction.commit()
return redirect("wiki:attachments_replace", attachment_id=self.attachment.id, return redirect("wiki:attachments_replace", attachment_id=self.attachment.id,
path=self.urlpath.path, article_id=self.article.id) path=self.urlpath.path, article_id=self.article.id)
except Exception: except Exception:
transaction.rollback()
messages.error(self.request, _(u'Your file could not be saved, probably because of a permission error on the web server.')) messages.error(self.request, _(u'Your file could not be saved, probably because of a permission error on the web server.'))
transaction.commit()
return redirect("wiki:attachments_replace", attachment_id=self.attachment.id, return redirect("wiki:attachments_replace", attachment_id=self.attachment.id,
path=self.urlpath.path, article_id=self.article.id) path=self.urlpath.path, article_id=self.article.id)
transaction.commit()
return redirect("wiki:attachments_index", path=self.urlpath.path, article_id=self.article.id) return redirect("wiki:attachments_index", path=self.urlpath.path, article_id=self.article.id)
def get_form(self, form_class): def get_form(self, form_class):
......
...@@ -15,7 +15,11 @@ ...@@ -15,7 +15,11 @@
$("#id_title").keyup(function () { $("#id_title").keyup(function () {
var e = $("#id_slug")[0]; var e = $("#id_slug")[0];
if(!e._changed) { if(!e._changed) {
e.value = URLify(this.value, 64); slug = URLify(this.value, 64);
wikislug = slug.replace(/\-/g, " ");
wikislug = wikislug.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1);});
wikislug = wikislug.replace(/\s*/g, "");
e.value = wikislug;
} }
}); });
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment