summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/locale/django.pot8
-rw-r--r--ishtar_common/static/media/style.css18
-rw-r--r--ishtar_common/templates/ishtar/blocks/window_nav.html3
-rw-r--r--ishtar_common/wizards.py40
4 files changed, 56 insertions, 13 deletions
diff --git a/ishtar_common/locale/django.pot b/ishtar_common/locale/django.pot
index aaae0cf76..771e1f2f2 100644
--- a/ishtar_common/locale/django.pot
+++ b/ishtar_common/locale/django.pot
@@ -359,7 +359,7 @@ msgstr ""
msgid "Account"
msgstr ""
-#: forms_common.py:467 wizards.py:1172
+#: forms_common.py:467 wizards.py:1192
msgid "New password"
msgstr ""
@@ -1432,7 +1432,7 @@ msgstr ""
msgid "No"
msgstr ""
-#: wizards.py:1229
+#: wizards.py:1249
#, python-format
msgid "[%(app_name)s] Account creation/modification"
msgstr ""
@@ -2100,6 +2100,10 @@ msgstr ""
msgid "Export as PDF file"
msgstr ""
+#: templates/ishtar/blocks/window_nav.html:49
+msgid "Relation between items are not historized."
+msgstr ""
+
#: templates/ishtar/blocks/window_tables/documents.html:10
msgid "Related to"
msgstr ""
diff --git a/ishtar_common/static/media/style.css b/ishtar_common/static/media/style.css
index c6a151dc8..4de3cd315 100644
--- a/ishtar_common/static/media/style.css
+++ b/ishtar_common/static/media/style.css
@@ -163,6 +163,14 @@ h4{
margin:10px 0;
}
+pre {
+ padding: 0.5em 1em;
+ white-space: pre-wrap;
+ white-space: -moz-pre-wrap;
+ white-space: -pre-wrap;
+ white-space: -o-pre-wrap;
+}
+
select{
max-width:550px;
}
@@ -621,8 +629,8 @@ ul.form-flex li li label {
padding:0.2em;
margin-left:auto;
margin-right:auto;
- width:600px;
background-color:#F1F2F6;
+ min-width: 600px;
}
.form table th{
@@ -1090,13 +1098,21 @@ p.alert{
color:#D14;
}
+p.info-box{
+ color: #1c94c4;
+}
+
div.form p.alert{
background-color:#FFF;
}
+#window p.info-box,
#window p.alert{
background-color:#EEE;
+ padding: 6px 16px;
padding-left: 30px;
+ width: auto;
+ margin: 6px 10px;
}
#window p.alert label{
diff --git a/ishtar_common/templates/ishtar/blocks/window_nav.html b/ishtar_common/templates/ishtar/blocks/window_nav.html
index c225a5822..13069b1eb 100644
--- a/ishtar_common/templates/ishtar/blocks/window_nav.html
+++ b/ishtar_common/templates/ishtar/blocks/window_nav.html
@@ -45,3 +45,6 @@
<a class='badge' href='{% url show_url item.pk "odt" %}' title='{% trans "Export as OpenOffice.org file"%}'>ODT</a> <a class='badge' href='{% url show_url item.pk "pdf" %}' title='{% trans "Export as PDF file"%}'>PDF</a>
</div>
<hr class='clear'>
+{% if next %}
+ <p class='info-box'><i class="fa fa-info-circle" aria-hidden="true"></i> <em>{% trans "Relation between items are not historized." %}</em></p>
+{% endif %}
diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py
index 7fc22f1a9..c8467ca61 100644
--- a/ishtar_common/wizards.py
+++ b/ishtar_common/wizards.py
@@ -32,7 +32,7 @@ from django.db.models.fields.files import FileField
from django.db.models.fields.related import ManyToManyField
from django.http import HttpResponseRedirect
from django.forms import ValidationError
-from django.shortcuts import render_to_response
+from django.shortcuts import render_to_response, redirect
from django.template import Context, RequestContext, loader
from django.utils.datastructures import MultiValueDict as BaseMultiValueDict
from django.utils.translation import ugettext_lazy as _
@@ -557,10 +557,15 @@ class Wizard(NamedUrlWizardView):
m2m_items = {}
# clear
# TODO! perf - to be really optimized
+ old_m2ms = {}
for model in whole_associated_models:
related_model = getattr(obj, model + 's')
# clear real m2m
if hasattr(related_model, 'clear'):
+ old_m2ms[model] = []
+ # stock items in order to not recreate them
+ for old_item in related_model.all():
+ old_m2ms[model].append(old_item)
related_model.clear()
else:
for r in related_model.all():
@@ -581,16 +586,32 @@ class Wizard(NamedUrlWizardView):
if value not in m2m_items[key]:
if type(value) == dict:
model = related_model.model
- if issubclass(model, models.BaseHistorizedItem):
- value['history_modifier'] = self.request.user
# not m2m -> foreign key
if not hasattr(related_model, 'clear'):
assert hasattr(model, 'MAIN_ATTR'), \
u"Must define a MAIN_ATTR for " + \
unicode(model.__class__)
value[getattr(model, 'MAIN_ATTR')] = obj
- value = model.objects.create(**value)
- value.save()
+
+ # check old links
+ my_old_item = None
+ if key in old_m2ms:
+ for old_item in old_m2ms[key]:
+ is_ok = True
+ for k in value:
+ if is_ok and getattr(old_item, k) != value[k]:
+ is_ok = False
+ continue
+ if is_ok:
+ my_old_item = old_item
+ break
+ if my_old_item:
+ value = my_old_item
+ else:
+ if issubclass(model, models.BaseHistorizedItem):
+ value['history_modifier'] = self.request.user
+ value = model.objects.create(**value)
+ value.save()
# check that an item is not add multiple times (forged forms)
if value not in related_model.all() and\
hasattr(related_model, 'add'):
@@ -632,7 +653,7 @@ class Wizard(NamedUrlWizardView):
return (to_delete, not_to_delete)
def get_form(self, step=None, data=None, files=None):
- """Manage formset"""
+ # Manage formset
if data:
data = data.copy()
if not step:
@@ -695,6 +716,7 @@ class Wizard(NamedUrlWizardView):
# for k in init[0]:
# data[step + '-' + unicode(total_field) + '-' + k] = \
# init[0][k]
+
data = data or None
form = super(Wizard, self).get_form(step, data, files)
# add autofocus to first field
@@ -723,6 +745,7 @@ class Wizard(NamedUrlWizardView):
if frm.fields[key].widget.source_full is not None:
frm.fields[key].widget.source_full = unicode(
frm.fields[key].widget.source_full) + "own/"
+
return form
def render_next_step(self, form, **kwargs):
@@ -760,10 +783,7 @@ class Wizard(NamedUrlWizardView):
except (ValueError, IndexError):
return super(Wizard, self).post(*args, **kwargs)
self.storage.current_step = wizard_goto_step
- form = self.get_form(
- data=self.storage.get_step_data(self.steps.current),
- files=self.storage.get_step_files(self.steps.current))
- return self.render(form)
+ return redirect(self.get_step_url(wizard_goto_step))
def session_get_keys(self, form_key):
"""Get list of available keys for a specific form