[Mpuls-commits] r5691 - in base/trunk/mpulsweb: lib templates/casemanagement templates/documents
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Dec 2 13:41:14 CET 2011
Author: ludwig
Date: 2011-12-02 13:41:14 +0100 (Fri, 02 Dec 2011)
New Revision: 5691
Modified:
base/trunk/mpulsweb/lib/validators.py
base/trunk/mpulsweb/templates/casemanagement/rename_attachment.mako
base/trunk/mpulsweb/templates/documents/global_rename.mako
Log:
Issue 2732: Reuse of the FileExistsChecker validator to check, if another
document with the same filename exists. Then an Invalid exception is raised.
Small change to the FileExistsChecker. If it gets an id, raises only the
exception, if the same name is thot that of the id.
This handles the case that the same name want to be used (and perhaps a
different description).
Modified: base/trunk/mpulsweb/lib/validators.py
===================================================================
--- base/trunk/mpulsweb/lib/validators.py 2011-12-02 11:47:00 UTC (rev 5690)
+++ base/trunk/mpulsweb/lib/validators.py 2011-12-02 12:41:14 UTC (rev 5691)
@@ -131,6 +131,10 @@
ow = field_dict[self.field_names[2]]
case = field_dict.get(self.field_names[3])
+ if len(self.field_names) >4:
+ id = field_dict.get(self.field_names[4])
+ else:
+ id = -1
if case:
sql = self.casedoc_sql
else:
@@ -146,9 +150,11 @@
cur = conn.cursor()
fields = {'filename': name, 'case': case}
cur.execute(sql, fields)
- result = cur.fetchone()
- if result:
- errors['name'] = self.message('fileexists', state)
+ result = cur.fetchall()
+ print "XXX val result " +str(result)
+ for r in result:
+ if int(r[0]) != id:
+ errors['name'] = self.message('fileexists', state)
except Exception, e:
log.exception(e)
raise
@@ -585,12 +591,17 @@
class RenameDocumentForm(BaseFormValidator):
+ file = Bool(if_missing=False)
name = String(not_empty=True)
+ overwrite = Bool(if_missing=False)
+ case = Int(if_missing=None)
+ id = Int(if_missing=None)
+ chained_validators = [FileExistsChecker('file', 'name', 'overwrite',
+ 'case', 'id')]
class RenameDocumentWDescForm(RenameDocumentForm):
description = String()
-
class UploadCaseDocumentForm(BaseFormValidator):
Modified: base/trunk/mpulsweb/templates/casemanagement/rename_attachment.mako
===================================================================
--- base/trunk/mpulsweb/templates/casemanagement/rename_attachment.mako 2011-12-02 11:47:00 UTC (rev 5690)
+++ base/trunk/mpulsweb/templates/casemanagement/rename_attachment.mako 2011-12-02 12:41:14 UTC (rev 5691)
@@ -2,7 +2,7 @@
<%inherit file="../main.mako" />
<%def name="buildNavipath()">
${parent.buildNavipath()}
- <li><a href="${h.url_for(controller='casedocument', action='overview')}">${_('Document overview')}</a></li>
+ <li><a href="${h.url_for(controller='casedocument', action='index', id=session.get('case').id)}">${_('Document overview')}</a></li>
</%def>
<div id="content_header_small">
@@ -13,7 +13,7 @@
<div class="actions">
<ul>
<li>
- <a href="${h.url_for(controller='casedocument', action='overview')}">
+ <a href="${h.url_for(controller='casedocument', action='index', id=session.get('case').id)}">
${_('Back to: user overview')}
</a>
</li>
@@ -53,6 +53,8 @@
<tr>
<td class=""></td>
<td colspan="2">
+ ${h.hidden('id', value=c.id)}
+ ${h.hidden('case', value=session.get('case').id)}
${h.submit('upload', _('Submit'))}
</td>
</tr>
Modified: base/trunk/mpulsweb/templates/documents/global_rename.mako
===================================================================
--- base/trunk/mpulsweb/templates/documents/global_rename.mako 2011-12-02 11:47:00 UTC (rev 5690)
+++ base/trunk/mpulsweb/templates/documents/global_rename.mako 2011-12-02 12:41:14 UTC (rev 5691)
@@ -54,6 +54,7 @@
<tr>
<td class=""></td>
<td colspan="2">
+ ${h.hidden('id', value=c.id)}
${h.submit('upload', _('Submit'))}
</td>
</tr>
More information about the Mpuls-commits
mailing list