[damned-lies] Catch action collision errors
- From: Claude Paroz <claudep src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [damned-lies] Catch action collision errors
- Date: Wed, 26 Aug 2009 07:31:32 +0000 (UTC)
commit 1b4cbcfb32a52d9701eee85ef5b266739e81cf8a
Author: Claude Paroz <claude 2xlibre net>
Date: Wed Aug 26 08:53:57 2009 +0200
Catch action collision errors
When someone reloads an already submitted action, or that someone else
posted an action in-between, the current action may be unvalid.
Catch it and display also the error on the top of the template,
because if there is a long list of action, the user may miss the
error message.
templates/vertimus/vertimus_detail.html | 4 ++++
vertimus/forms.py | 5 ++++-
2 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/templates/vertimus/vertimus_detail.html b/templates/vertimus/vertimus_detail.html
index b6f49f2..e6759e2 100644
--- a/templates/vertimus/vertimus_detail.html
+++ b/templates/vertimus/vertimus_detail.html
@@ -17,6 +17,10 @@ $(document).ready(function() {
{% block content %}
<div class="mainpage">
+{% if action_form.non_field_errors %}
+ {{ action_form.non_field_errors }}
+{% endif %}
+
{% with branch.releases.all as releases %}
<div class="release_link">
{% if releases %}
diff --git a/vertimus/forms.py b/vertimus/forms.py
index d147500..d102940 100644
--- a/vertimus/forms.py
+++ b/vertimus/forms.py
@@ -66,7 +66,10 @@ class ActionForm(forms.Form):
def clean(self):
cleaned_data = self.cleaned_data
- action = ActionAbstract.new_by_name(cleaned_data.get('action'))
+ action_code = cleaned_data.get('action')
+ if action_code is None:
+ raise forms.ValidationError(_("Unvalid action. Someone probably posted another action just before you."))
+ action = ActionAbstract.new_by_name(action_code)
comment = cleaned_data.get('comment')
file = cleaned_data.get('file')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]