summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/__init__.py6
-rw-r--r--ishtar_common/data_importer.py9
-rw-r--r--ishtar_common/forms_common.py15
-rw-r--r--ishtar_common/locale/django.pot453
-rw-r--r--ishtar_common/management/commands/ishtar_import.py38
-rw-r--r--ishtar_common/models.py21
-rw-r--r--ishtar_common/templates/blocks/JQueryJqGrid.html1
-rw-r--r--ishtar_common/templates/blocks/inline_formset.html2
-rw-r--r--ishtar_common/templates/ishtar/blocks/window_field_url.html3
-rw-r--r--ishtar_common/templates/ishtar/sheet.html4
-rw-r--r--ishtar_common/templates/ishtar/sheet_source.html24
-rw-r--r--ishtar_common/templates/ishtar/sheet_toolbar.html2
-rw-r--r--ishtar_common/templates/ishtar/wizard/relations_wizard.html32
-rw-r--r--ishtar_common/templatetags/inline_formset.py7
-rw-r--r--ishtar_common/templatetags/link_to_window.py26
-rw-r--r--ishtar_common/templatetags/window_field.py12
-rw-r--r--ishtar_common/views.py30
-rw-r--r--ishtar_common/wizards.py30
18 files changed, 453 insertions, 262 deletions
diff --git a/ishtar_common/__init__.py b/ishtar_common/__init__.py
index 7b8a90c36..84ec7c204 100644
--- a/ishtar_common/__init__.py
+++ b/ishtar_common/__init__.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (C) 2014 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
+# Copyright (C) 2014-2015 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
from django.utils.translation import ugettext as _
@@ -10,8 +10,10 @@ _(u"email address")
VERSION = (0, 9)
+_(u"Related item")
+
+
def get_version():
return u'.'.join((unicode(num) for num in VERSION))
__version__ = get_version()
-
diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py
index 34f8ebec8..09ef64c26 100644
--- a/ishtar_common/data_importer.py
+++ b/ishtar_common/data_importer.py
@@ -1180,6 +1180,15 @@ class Importer(object):
# contruct many dict for each values
default_dict = {}
+
+ # # get default values
+ p = [attribute]
+ if c_path:
+ p = list(c_path) + p
+ p = tuple(p)
+ if p in self._defaults:
+ for k in self._defaults[p]:
+ default_dict[k] = self._defaults[p][k]
# # init with simple values that will be duplicated
for key in val.keys():
if type(val[key]) not in (list, tuple):
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py
index 93f6b9ec6..f194caffa 100644
--- a/ishtar_common/forms_common.py
+++ b/ishtar_common/forms_common.py
@@ -574,12 +574,24 @@ class SourceForm(forms.Form):
title = forms.CharField(label=_(u"Title"),
validators=[validators.MaxLengthValidator(200)])
source_type = forms.ChoiceField(label=_(u"Source type"), choices=[])
+ reference = forms.CharField(
+ label=_(u"Reference"),
+ validators=[validators.MaxLengthValidator(100)], required=False)
+ internal_reference = forms.CharField(
+ label=_(u"Internal reference"),
+ validators=[validators.MaxLengthValidator(100)], required=False)
associated_url = forms.URLField(
required=False, label=_(u"Numerical ressource (web address)"))
receipt_date = forms.DateField(label=_(u"Receipt date"), required=False,
widget=widgets.JQueryDate)
creation_date = forms.DateField(label=_(u"Creation date"), required=False,
widget=widgets.JQueryDate)
+ comment = forms.CharField(label=_(u"Comment"), widget=forms.Textarea,
+ required=False)
+ description = forms.CharField(label=_(u"Description"),
+ widget=forms.Textarea, required=False)
+ duplicate = forms.BooleanField(label=_(u"Has a duplicate"),
+ required=False)
def __init__(self, *args, **kwargs):
super(SourceForm, self).__init__(*args, **kwargs)
@@ -595,6 +607,9 @@ class SourceSelect(TableSelect):
required=False)
source_type = forms.ChoiceField(label=_("Source type"), choices=[])
+ reference = forms.CharField(label=_(u"Reference"))
+ internal_reference = forms.CharField(label=_(u"Internal reference"))
+ duplicate = forms.NullBooleanField(label=_(u"Has a duplicate"))
def __init__(self, *args, **kwargs):
super(SourceSelect, self).__init__(*args, **kwargs)
diff --git a/ishtar_common/locale/django.pot b/ishtar_common/locale/django.pot
index f4deb1cbf..338719184 100644
--- a/ishtar_common/locale/django.pot
+++ b/ishtar_common/locale/django.pot
@@ -18,7 +18,7 @@ msgstr ""
msgid "Archaeological file"
msgstr ""
-#: context_processors.py:34 models.py:1110
+#: context_processors.py:34 models.py:1133
msgid "Operation"
msgstr ""
@@ -141,7 +141,7 @@ msgstr ""
msgid "Enter a valid name consisting of letters, spaces and hyphens."
msgstr ""
-#: forms.py:71 forms_common.py:419
+#: forms.py:71 forms_common.py:420
msgid "Confirm"
msgstr ""
@@ -165,15 +165,14 @@ msgstr ""
msgid "Add a new item"
msgstr ""
-#: forms.py:171 models.py:970
+#: forms.py:171 models.py:993
msgid "Template"
msgstr ""
#: forms_common.py:39 forms_common.py:57 forms_common.py:169
-#: forms_common.py:268 forms_common.py:273 models.py:1036 models.py:2168
+#: forms_common.py:269 forms_common.py:274 models.py:1059 models.py:2202
#: templates/blocks/JQueryAdvancedTown.html:19
#: templates/ishtar/sheet_organization.html:17
-#: templates/ishtar/sheet_person.html:30
msgid "Town"
msgstr ""
@@ -187,70 +186,64 @@ msgid ""
"french town Saint-Denis in the Seine-Saint-Denis department.</p>"
msgstr ""
-#: forms_common.py:66 forms_common.py:621 ishtar_menu.py:40 models.py:1895
-#: models.py:2007 models.py:2061 templates/ishtar/sheet_person.html:6
+#: forms_common.py:66 forms_common.py:622 ishtar_menu.py:42 models.py:1918
+#: models.py:2041 models.py:2095 templates/ishtar/sheet_person.html:6
msgid "Person"
msgstr ""
-#: forms_common.py:157 forms_common.py:231 ishtar_menu.py:58 models.py:1824
+#: forms_common.py:157 forms_common.py:231 ishtar_menu.py:66 models.py:1847
#: templates/ishtar/sheet_organization.html:6
msgid "Organization"
msgstr ""
#: forms_common.py:160 forms_common.py:196 forms_common.py:226
-#: forms_common.py:259 models.py:969 models.py:1158 models.py:1375
-#: models.py:1818 models.py:1885 models.py:2154
+#: forms_common.py:259 models.py:992 models.py:1181 models.py:1398
+#: models.py:1841 models.py:1908 models.py:2188
#: templates/ishtar/sheet_organization.html:12
#: templates/ishtar/sheet_organization.html:25
-#: templates/ishtar/sheet_person.html:26
msgid "Name"
msgstr ""
-#: forms_common.py:161 models.py:1105 models.py:1506
+#: forms_common.py:161 models.py:1128 models.py:1529
msgid "Organization type"
msgstr ""
-#: forms_common.py:163 forms_common.py:262 models.py:1031
+#: forms_common.py:163 forms_common.py:263 models.py:1054
#: templates/ishtar/sheet_organization.html:14
-#: templates/ishtar/sheet_person.html:27
msgid "Address"
msgstr ""
-#: forms_common.py:165 forms_common.py:264 models.py:1032
+#: forms_common.py:165 forms_common.py:265 models.py:1055
#: templates/ishtar/sheet_organization.html:15
-#: templates/ishtar/sheet_person.html:28
msgid "Address complement"
msgstr ""
-#: forms_common.py:167 forms_common.py:266 models.py:1034
+#: forms_common.py:167 forms_common.py:267 models.py:1057
#: templates/ishtar/sheet_organization.html:16
-#: templates/ishtar/sheet_person.html:29
msgid "Postal code"
msgstr ""
-#: forms_common.py:170 forms_common.py:269 models.py:1037
+#: forms_common.py:170 forms_common.py:270 models.py:1060
msgid "Country"
msgstr ""
-#: forms_common.py:172 forms_common.py:228 forms_common.py:271
-#: forms_common.py:375 models.py:1043
+#: forms_common.py:172 forms_common.py:228 forms_common.py:272
+#: forms_common.py:376 models.py:1066
msgid "Email"
msgstr ""
-#: forms_common.py:173 forms_common.py:272 models.py:1039
+#: forms_common.py:173 forms_common.py:273 models.py:1062
#: templates/ishtar/sheet_organization.html:18
-#: templates/ishtar/sheet_person.html:31
msgid "Phone"
msgstr ""
-#: forms_common.py:174 models.py:1040
+#: forms_common.py:174 models.py:1063
#: templates/ishtar/sheet_organization.html:19
-#: templates/ishtar/sheet_person.html:32
msgid "Mobile phone"
msgstr ""
-#: forms_common.py:197 forms_common.py:229 models.py:1529 models.py:1820
-#: models.py:2102 templates/sheet_ope.html:85 templates/sheet_ope.html.py:105
+#: forms_common.py:197 forms_common.py:229 models.py:1552 models.py:1843
+#: models.py:2136 templates/sheet_ope.html:85 templates/sheet_ope.html.py:105
#: templates/sheet_ope.html:126 templates/ishtar/import_list.html:13
#: templates/ishtar/sheet_organization.html:27
#: templates/ishtar/sheet_person.html:56
@@ -262,7 +255,7 @@ msgstr ""
msgid "Organization search"
msgstr ""
-#: forms_common.py:227 forms_common.py:257 models.py:1883
+#: forms_common.py:227 forms_common.py:257 models.py:1906
#: templates/ishtar/sheet_organization.html:26
msgid "Surname"
msgstr ""
@@ -275,160 +268,160 @@ msgstr ""
msgid "Identity"
msgstr ""
-#: forms_common.py:256 forms_common.py:573 models.py:1881 models.py:2099
+#: forms_common.py:256 forms_common.py:574 models.py:1904 models.py:2133
#: templates/sheet_ope.html:104 templates/ishtar/sheet_person.html:55
#: templates/ishtar/blocks/window_tables/documents.html:5
msgid "Title"
msgstr ""
-#: forms_common.py:261 models.py:1887
+#: forms_common.py:261 models.py:1910
msgid "Raw name"
msgstr ""
-#: forms_common.py:276
+#: forms_common.py:277
msgid "Current organization"
msgstr ""
-#: forms_common.py:324 forms_common.py:354 forms_common.py:358 models.py:1865
+#: forms_common.py:325 forms_common.py:355 forms_common.py:359 models.py:1888
msgid "Person type"
msgstr ""
-#: forms_common.py:369 forms_common.py:374
+#: forms_common.py:370 forms_common.py:375
msgid "Account"
msgstr ""
-#: forms_common.py:378 wizards.py:1029
+#: forms_common.py:379 wizards.py:1141
msgid "New password"
msgstr ""
-#: forms_common.py:381
+#: forms_common.py:382
msgid "New password (confirmation)"
msgstr ""
-#: forms_common.py:400
+#: forms_common.py:401
msgid "Your password and confirmation password do not match."
msgstr ""
-#: forms_common.py:405
+#: forms_common.py:406
msgid "You must provide a correct password."
msgstr ""
-#: forms_common.py:413
+#: forms_common.py:414
msgid "This username already exists."
msgstr ""
-#: forms_common.py:420
+#: forms_common.py:421
msgid "Send the new password by email?"
msgstr ""
-#: forms_common.py:429 forms_common.py:442 models.py:2169
+#: forms_common.py:430 forms_common.py:443 models.py:2203
msgid "Towns"
msgstr ""
-#: forms_common.py:439
+#: forms_common.py:440
msgid "There are identical towns."
msgstr ""
-#: forms_common.py:523
+#: forms_common.py:524
msgid "Only one choice can be checked."
msgstr ""
-#: forms_common.py:571
+#: forms_common.py:572
msgid "Documentation informations"
msgstr ""
-#: forms_common.py:575 forms_common.py:596 models.py:1507 models.py:2082
+#: forms_common.py:576 forms_common.py:597 models.py:1530 models.py:2116
msgid "Source type"
msgstr ""
-#: forms_common.py:577 models.py:2113
+#: forms_common.py:578 models.py:2147
msgid "Numerical ressource (web address)"
msgstr ""
-#: forms_common.py:578 models.py:2115
+#: forms_common.py:579 models.py:2149
msgid "Receipt date"
msgstr ""
-#: forms_common.py:580 models.py:1656 models.py:2117
+#: forms_common.py:581 models.py:1679 models.py:2151
msgid "Creation date"
msgstr ""
-#: forms_common.py:593 forms_common.py:614 forms_common.py:647 models.py:2066
+#: forms_common.py:594 forms_common.py:615 forms_common.py:648 models.py:2100
#: templates/ishtar/wizard/wizard_person_deletion.html:124
msgid "Author"
msgstr ""
-#: forms_common.py:606
+#: forms_common.py:607
msgid "Would you like to delete this documentation?"
msgstr ""
-#: forms_common.py:622 models.py:1508 models.py:2056 models.py:2063
+#: forms_common.py:623 models.py:1531 models.py:2090 models.py:2097
msgid "Author type"
msgstr ""
-#: forms_common.py:640
+#: forms_common.py:641
msgid "Author selection"
msgstr ""
-#: forms_common.py:654
+#: forms_common.py:655
msgid "There are identical authors."
msgstr ""
-#: forms_common.py:658 models.py:2067 models.py:2109
+#: forms_common.py:659 models.py:2101 models.py:2143
#: templates/sheet_ope.html:106
#: templates/ishtar/blocks/window_tables/documents.html:7
msgid "Authors"
msgstr ""
-#: ishtar_menu.py:28
+#: ishtar_menu.py:29
msgid "Administration"
msgstr ""
-#: ishtar_menu.py:30 views.py:135
+#: ishtar_menu.py:31 views.py:135
msgid "Account management"
msgstr ""
-#: ishtar_menu.py:33 models.py:753 views.py:1075
+#: ishtar_menu.py:34 models.py:776 views.py:1077
msgid "Global variables"
msgstr ""
-#: ishtar_menu.py:38
+#: ishtar_menu.py:39
msgid "Directory"
msgstr ""
-#: ishtar_menu.py:42 ishtar_menu.py:60 templates/blocks/JQueryJqGrid.html:4
+#: ishtar_menu.py:45 ishtar_menu.py:69 templates/blocks/JQueryJqGrid.html:4
msgid "Search"
msgstr ""
-#: ishtar_menu.py:45 ishtar_menu.py:64 templates/ishtar/import_list.html:15
+#: ishtar_menu.py:49 ishtar_menu.py:74 templates/ishtar/import_list.html:15
msgid "Creation"
msgstr ""
-#: ishtar_menu.py:48 ishtar_menu.py:68
+#: ishtar_menu.py:53 ishtar_menu.py:79
msgid "Modification"
msgstr ""
-#: ishtar_menu.py:51 ishtar_menu.py:72 templates/ishtar/merge.html:5
+#: ishtar_menu.py:57 ishtar_menu.py:84 templates/ishtar/merge.html:5
msgid "Merge"
msgstr ""
-#: ishtar_menu.py:54 ishtar_menu.py:75 models.py:1693 widgets.py:110
+#: ishtar_menu.py:61 ishtar_menu.py:88 models.py:1716 widgets.py:110
msgid "Delete"
msgstr ""
-#: ishtar_menu.py:82 models.py:1667
+#: ishtar_menu.py:96 models.py:1690
msgid "Imports"
msgstr ""
-#: ishtar_menu.py:84 views.py:1083
+#: ishtar_menu.py:99 views.py:1085
msgid "New import"
msgstr ""
-#: ishtar_menu.py:87 views.py:1097
+#: ishtar_menu.py:103 views.py:1099
msgid "Current imports"
msgstr ""
-#: ishtar_menu.py:90
+#: ishtar_menu.py:107
msgid "Old imports"
msgstr ""
@@ -444,7 +437,7 @@ msgstr ""
msgid "This item already exist."
msgstr ""
-#: models.py:256 models.py:1004 models.py:1016
+#: models.py:256 models.py:1027 models.py:1039
msgid "Label"
msgstr ""
@@ -452,613 +445,613 @@ msgstr ""
msgid "Textual ID"
msgstr ""
-#: models.py:260 models.py:1402 models.py:2124
+#: models.py:260 models.py:1425 models.py:2158
msgid "Comment"
msgstr ""
-#: models.py:261 models.py:973
+#: models.py:261 models.py:996
msgid "Available"
msgstr ""
-#: models.py:451 models.py:1448
+#: models.py:474 models.py:1471
msgid "Key"
msgstr ""
-#: models.py:457
+#: models.py:480
msgid "Key specific to an import"
msgstr ""
-#: models.py:528
+#: models.py:551
msgid "Last editor"
msgstr ""
-#: models.py:531
+#: models.py:554
msgid "Creator"
msgstr ""
-#: models.py:664 models.py:2180
+#: models.py:687 models.py:2214
msgid "Order"
msgstr ""
-#: models.py:665
+#: models.py:688
msgid "Symmetrical"
msgstr ""
-#: models.py:678
+#: models.py:701
msgid "Cannot have symmetrical and an inverse_relation"
msgstr ""
-#: models.py:746
+#: models.py:769
msgid "Variable name"
msgstr ""
-#: models.py:747
+#: models.py:770
msgid "Description of the variable"
msgstr ""
-#: models.py:749 models.py:1449
+#: models.py:772 models.py:1472
msgid "Value"
msgstr ""
-#: models.py:752
+#: models.py:775
msgid "Global variable"
msgstr ""
-#: models.py:874 models.py:904
+#: models.py:897 models.py:927
msgid "Total"
msgstr ""
-#: models.py:881 models.py:1005 models.py:1017
+#: models.py:904 models.py:1028 models.py:1040
#: templates/ishtar/dashboards/dashboard_main_detail.html:135
#: templates/ishtar/dashboards/dashboard_main_detail_users.html:26
msgid "Number"
msgstr ""
-#: models.py:968
+#: models.py:991
msgid "Administrative Act"
msgstr ""
-#: models.py:972
+#: models.py:995
msgid "Associated object"
msgstr ""
-#: models.py:976
+#: models.py:999
msgid "Document template"
msgstr ""
-#: models.py:977
+#: models.py:1000
msgid "Document templates"
msgstr ""
-#: models.py:1008 models.py:1018 models.py:1651
+#: models.py:1031 models.py:1041 models.py:1674
msgid "State"
msgstr ""
-#: models.py:1022 templates/blocks/JQueryAdvancedTown.html:12
+#: models.py:1045 templates/blocks/JQueryAdvancedTown.html:12
msgid "Department"
msgstr ""
-#: models.py:1023
+#: models.py:1046
msgid "Departments"
msgstr ""
-#: models.py:1051
+#: models.py:1074
msgid "Merge key"
msgstr ""
-#: models.py:1106
+#: models.py:1129
msgid "Organization types"
msgstr ""
-#: models.py:1111
+#: models.py:1134
msgid "Parcels"
msgstr ""
-#: models.py:1113
+#: models.py:1136
msgid "Operation source"
msgstr ""
-#: models.py:1119 views.py:890 views.py:947
+#: models.py:1142 views.py:892 views.py:949
msgid "Archaeological files"
msgstr ""
-#: models.py:1126 views.py:893 views.py:957
+#: models.py:1149 views.py:895 views.py:959
msgid "Context records"
msgstr ""
-#: models.py:1129 views.py:895 views.py:962
+#: models.py:1152 views.py:897 views.py:964
msgid "Finds"
msgstr ""
-#: models.py:1160
+#: models.py:1183
msgid "Slug"
msgstr ""
-#: models.py:1162 models.py:1334 models.py:1376 models.py:2123
+#: models.py:1185 models.py:1357 models.py:1399 models.py:2157
#: templates/sheet_ope.html:128
msgid "Description"
msgstr ""
-#: models.py:1164 templates/ishtar/dashboards/dashboard_main.html:26
+#: models.py:1187 templates/ishtar/dashboards/dashboard_main.html:26
msgid "Users"
msgstr ""
-#: models.py:1166
+#: models.py:1189
msgid "Associated model"
msgstr ""
-#: models.py:1168
+#: models.py:1191
msgid "Is template"
msgstr ""
-#: models.py:1169
+#: models.py:1192
msgid "Unicity keys (separator \";\")"
msgstr ""
-#: models.py:1173
+#: models.py:1196
msgid "Importer - Type"
msgstr ""
-#: models.py:1174
+#: models.py:1197
msgid "Importer - Types"
msgstr ""
-#: models.py:1264
+#: models.py:1287
msgid "Importer - Default"
msgstr ""
-#: models.py:1265
+#: models.py:1288
msgid "Importer - Defaults"
msgstr ""
-#: models.py:1300
+#: models.py:1323
msgid "Importer - Default value"
msgstr ""
-#: models.py:1301
+#: models.py:1324
msgid "Importer - Default values"
msgstr ""
-#: models.py:1333
+#: models.py:1356
msgid "Column number"
msgstr ""
-#: models.py:1336
+#: models.py:1359
msgid "Required"
msgstr ""
-#: models.py:1339
+#: models.py:1362
msgid "Importer - Column"
msgstr ""
-#: models.py:1340
+#: models.py:1363
msgid "Importer - Columns"
msgstr ""
-#: models.py:1360
+#: models.py:1383
msgid "Field name"
msgstr ""
-#: models.py:1362 models.py:1396
+#: models.py:1385 models.py:1419
msgid "Force creation of new item"
msgstr ""
-#: models.py:1364 models.py:1398
+#: models.py:1387 models.py:1421
msgid "Concatenate with existing"
msgstr ""
-#: models.py:1366 models.py:1400
+#: models.py:1389 models.py:1423
msgid "Concatenate character"
msgstr ""
-#: models.py:1370
+#: models.py:1393
msgid "Importer - Duplicate field"
msgstr ""
-#: models.py:1371
+#: models.py:1394
msgid "Importer - Duplicate fields"
msgstr ""
-#: models.py:1378
+#: models.py:1401
msgid "Regular expression"
msgstr ""
-#: models.py:1381
+#: models.py:1404
msgid "Importer - Regular expression"
msgstr ""
-#: models.py:1382
+#: models.py:1405
msgid "Importer - Regular expressions"
msgstr ""
-#: models.py:1405
+#: models.py:1428
msgid "Importer - Target"
msgstr ""
-#: models.py:1406
+#: models.py:1429
msgid "Importer - Targets"
msgstr ""
-#: models.py:1430 views.py:306
+#: models.py:1453 views.py:306
msgid "True"
msgstr ""
-#: models.py:1431 views.py:308
+#: models.py:1454 views.py:308
msgid "False"
msgstr ""
-#: models.py:1450
+#: models.py:1473
msgid "Is set"
msgstr ""
-#: models.py:1457
+#: models.py:1480
msgid "Importer - Target key"
msgstr ""
-#: models.py:1458
+#: models.py:1481
msgid "Importer - Targets keys"
msgstr ""
-#: models.py:1509 models.py:2094 models.py:2105
+#: models.py:1532 models.py:2128 models.py:2139
msgid "Format"
msgstr ""
-#: models.py:1510 models.py:2184
+#: models.py:1533 models.py:2218
msgid "Operation type"
msgstr ""
-#: models.py:1511
+#: models.py:1534
msgid "Period"
msgstr ""
-#: models.py:1512
+#: models.py:1535
msgid "Unit"
msgstr ""
-#: models.py:1513
+#: models.py:1536
msgid "Material"
msgstr ""
-#: models.py:1515
+#: models.py:1538
msgid "Conservatory state"
msgstr ""
-#: models.py:1516
+#: models.py:1539
msgid "Preservation type"
msgstr ""
-#: models.py:1517
+#: models.py:1540
msgid "Object type"
msgstr ""
-#: models.py:1519
+#: models.py:1542
msgid "Identification type"
msgstr ""
-#: models.py:1525
+#: models.py:1548
msgid "Integer"
msgstr ""
-#: models.py:1526
+#: models.py:1549
msgid "Float"
msgstr ""
-#: models.py:1527
+#: models.py:1550
msgid "String"
msgstr ""
-#: models.py:1528 templates/sheet_ope.html:86
+#: models.py:1551 templates/sheet_ope.html:86
msgid "Date"
msgstr ""
-#: models.py:1530 templates/sheet_ope.html:61 templates/sheet_ope.html.py:83
+#: models.py:1553 templates/sheet_ope.html:61 templates/sheet_ope.html.py:83
#: templates/ishtar/sheet_person.html:54
#: templates/ishtar/dashboards/dashboard_main_detail.html:120
msgid "Year"
msgstr ""
-#: models.py:1531
+#: models.py:1554
msgid "String to boolean"
msgstr ""
-#: models.py:1532
+#: models.py:1555
msgctxt "filesystem"
msgid "File"
msgstr ""
-#: models.py:1533
+#: models.py:1556
msgid "Unknow type"
msgstr ""
-#: models.py:1549
+#: models.py:1572
msgid "4 digit year. e.g.: \"2015\""
msgstr ""
-#: models.py:1550
+#: models.py:1573
msgid "4 digit year/month/day. e.g.: \"2015/02/04\""
msgstr ""
-#: models.py:1551
+#: models.py:1574
msgid "Day/month/4 digit year. e.g.: \"04/02/2015\""
msgstr ""
-#: models.py:1561
+#: models.py:1584
msgid "Options"
msgstr ""
-#: models.py:1563
+#: models.py:1586
msgid "Split character(s)"
msgstr ""
-#: models.py:1567
+#: models.py:1590
msgid "Importer - Formater type"
msgstr ""
-#: models.py:1568
+#: models.py:1591
msgid "Importer - Formater types"
msgstr ""
-#: models.py:1615 templates/ishtar/dashboards/dashboard_main_detail.html:61
+#: models.py:1638 templates/ishtar/dashboards/dashboard_main_detail.html:61
msgid "Created"
msgstr ""
-#: models.py:1616
+#: models.py:1639
msgid "Analyse in progress"
msgstr ""
-#: models.py:1617
+#: models.py:1640
msgid "Analysed"
msgstr ""
-#: models.py:1618
+#: models.py:1641
msgid "Import pending"
msgstr ""
-#: models.py:1619
+#: models.py:1642
msgid "Import in progress"
msgstr ""
-#: models.py:1620
+#: models.py:1643
msgid "Finished with errors"
msgstr ""
-#: models.py:1621
+#: models.py:1644
msgid "Finished"
msgstr ""
-#: models.py:1622
+#: models.py:1645
msgid "Archived"
msgstr ""
-#: models.py:1634
+#: models.py:1657
msgid "Imported file"
msgstr ""
-#: models.py:1637
+#: models.py:1660
msgid "Associated images (zip file)"
msgstr ""
-#: models.py:1639
+#: models.py:1662
msgid "Encoding"
msgstr ""
-#: models.py:1641
+#: models.py:1664
msgid "Skip lines"
msgstr ""
-#: models.py:1642 templates/ishtar/import_list.html:47
+#: models.py:1665 templates/ishtar/import_list.html:47
msgid "Error file"
msgstr ""
-#: models.py:1645
+#: models.py:1668
msgid "Result file"
msgstr ""
-#: models.py:1648 templates/ishtar/import_list.html:53
+#: models.py:1671 templates/ishtar/import_list.html:53
msgid "Match file"
msgstr ""
-#: models.py:1654
+#: models.py:1677
msgid "Conservative import"
msgstr ""
-#: models.py:1659
+#: models.py:1682
msgid "End date"
msgstr ""
-#: models.py:1661
+#: models.py:1684
msgid "Seconds remaining"
msgstr ""
-#: models.py:1666
+#: models.py:1689
msgid "Import"
msgstr ""
-#: models.py:1683
+#: models.py:1706
msgid "Analyse"
msgstr ""
-#: models.py:1685 models.py:1688
+#: models.py:1708 models.py:1711
msgid "Re-analyse"
msgstr ""
-#: models.py:1686
+#: models.py:1709
msgid "Launch import"
msgstr ""
-#: models.py:1689
+#: models.py:1712
msgid "Re-import"
msgstr ""
-#: models.py:1690
+#: models.py:1713
msgid "Archive"
msgstr ""
-#: models.py:1692
+#: models.py:1715
msgid "Unarchive"
msgstr ""
-#: models.py:1825
+#: models.py:1848
msgid "Organizations"
msgstr ""
-#: models.py:1827
+#: models.py:1850
msgid "Can view all Organization"
msgstr ""
-#: models.py:1828
+#: models.py:1851
msgid "Can view own Organization"
msgstr ""
-#: models.py:1829
+#: models.py:1852
msgid "Can add own Organization"
msgstr ""
-#: models.py:1831
+#: models.py:1854
msgid "Can change own Organization"
msgstr ""
-#: models.py:1833
+#: models.py:1856
msgid "Can delete own Organization"
msgstr ""
-#: models.py:1861
+#: models.py:1884
msgid "Groups"
msgstr ""
-#: models.py:1866
+#: models.py:1889
msgid "Person types"
msgstr ""
-#: models.py:1873
+#: models.py:1896
msgid "Mr"
msgstr ""
-#: models.py:1874
+#: models.py:1897
msgid "Miss"
msgstr ""
-#: models.py:1875
+#: models.py:1898
msgid "Mr and Miss"
msgstr ""
-#: models.py:1876
+#: models.py:1899
msgid "Mrs"
msgstr ""
-#: models.py:1877
+#: models.py:1900
msgid "Doctor"
msgstr ""
-#: models.py:1889 models.py:1929
+#: models.py:1912 models.py:1952
msgid "Types"
msgstr ""
-#: models.py:1892
+#: models.py:1915
msgid "Is attached to"
msgstr ""
-#: models.py:1896
+#: models.py:1919
msgid "Persons"
msgstr ""
-#: models.py:1898
+#: models.py:1921
msgid "Can view all Person"
msgstr ""
-#: models.py:1899
+#: models.py:1922
msgid "Can view own Person"
msgstr ""
-#: models.py:1900
+#: models.py:1923
msgid "Can add own Person"
msgstr ""
-#: models.py:1901
+#: models.py:1924
msgid "Can change own Person"
msgstr ""
-#: models.py:1902
+#: models.py:1925
msgid "Can delete own Person"
msgstr ""
-#: models.py:2011
+#: models.py:2045
msgid "Ishtar user"
msgstr ""
-#: models.py:2012
+#: models.py:2046
msgid "Ishtar users"
msgstr ""
-#: models.py:2057
+#: models.py:2091
msgid "Author types"
msgstr ""
-#: models.py:2083
+#: models.py:2117
msgid "Source types"
msgstr ""
-#: models.py:2088
+#: models.py:2122
msgid "Support type"
msgstr ""
-#: models.py:2089
+#: models.py:2123
msgid "Support types"
msgstr ""
-#: models.py:2095
+#: models.py:2129
msgid "Formats"
msgstr ""
-#: models.py:2100
+#: models.py:2134
msgid "External ID"
msgstr ""
-#: models.py:2103
+#: models.py:2137
msgid "Support"
msgstr ""
-#: models.py:2107
+#: models.py:2141
msgid "Scale"
msgstr ""
-#: models.py:2118
+#: models.py:2152
msgid "Item number"
msgstr ""
-#: models.py:2119
+#: models.py:2153
msgid "Ref."
msgstr ""
-#: models.py:2121
+#: models.py:2155
msgid "Internal reference"
msgstr ""
-#: models.py:2125
+#: models.py:2159
msgid "Additional information"
msgstr ""
-#: models.py:2155
+#: models.py:2189
msgid "Surface (m2)"
msgstr ""
-#: models.py:2156 templates/sheet_ope.html:46 templates/sheet_ope.html.py:107
+#: models.py:2190 templates/sheet_ope.html:46 templates/sheet_ope.html.py:107
msgid "Localisation"
msgstr ""
-#: models.py:2181
+#: models.py:2215
msgid "Is preventive"
msgstr ""
-#: models.py:2185
+#: models.py:2219
msgid "Operation types"
msgstr ""
-#: models.py:2211
+#: models.py:2245
msgid "Preventive"
msgstr ""
-#: models.py:2212
+#: models.py:2246
msgid "Research"
msgstr ""
@@ -1090,33 +1083,33 @@ msgstr ""
msgid "Organization deletion"
msgstr ""
-#: views.py:592 templates/base.html:80
+#: views.py:594 templates/base.html:80
#: templates/ishtar/sheet_organization.html:35
msgid "Details"
msgstr ""
-#: views.py:820 views.py:873
+#: views.py:822 views.py:875
msgid "Operation not permitted."
msgstr ""
-#: views.py:822
+#: views.py:824
#, python-format
msgid "New %s"
msgstr ""
-#: views.py:891 views.py:951
+#: views.py:893 views.py:953
msgid "Operations"
msgstr ""
-#: views.py:1144 templates/ishtar/import_list.html:43
+#: views.py:1146 templates/ishtar/import_list.html:43
msgid "Link unmatched items"
msgstr ""
-#: views.py:1159
+#: views.py:1161
msgid "Delete import"
msgstr ""
-#: views.py:1218 views.py:1234
+#: views.py:1220 views.py:1236
msgid "Corporation manager"
msgstr ""
@@ -1136,15 +1129,15 @@ msgstr ""
msgid "Remove"
msgstr ""
-#: wizards.py:242 templates/ishtar/import_delete.html:20
+#: wizards.py:313 templates/ishtar/import_delete.html:20
msgid "Yes"
msgstr ""
-#: wizards.py:244
+#: wizards.py:315
msgid "No"
msgstr ""
-#: wizards.py:1085
+#: wizards.py:1198
#, python-format
msgid "[%(app_name)s] Account creation/modification"
msgstr ""
@@ -1654,7 +1647,7 @@ msgstr ""
msgid "Link"
msgstr ""
-#: templates/ishtar/sheet_person.html:68
+#: templates/ishtar/sheet_person.html:69
msgid "No document associated to this person"
msgstr ""
@@ -1759,6 +1752,7 @@ msgstr ""
#: templates/ishtar/wizard/default_wizard.html:35
#: templates/ishtar/wizard/parcels_wizard.html:24
+#: templates/ishtar/wizard/relations_wizard.html:23
#: templates/ishtar/wizard/search.html:20
#: templates/ishtar/wizard/towns_wizard.html:19
msgid "Add/Modify"
@@ -1776,6 +1770,7 @@ msgid ""
msgstr ""
#: templates/ishtar/wizard/parcels_wizard.html:20
+#: templates/ishtar/wizard/relations_wizard.html:20
msgid "all"
msgstr ""
diff --git a/ishtar_common/management/commands/ishtar_import.py b/ishtar_common/management/commands/ishtar_import.py
new file mode 100644
index 000000000..aba1e45d5
--- /dev/null
+++ b/ishtar_common/management/commands/ishtar_import.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from django.core.management.base import BaseCommand, CommandError
+
+from ishtar_common import models
+
+
+class Command(BaseCommand):
+ help = "./manage.py ishtar_import <command> <import_id>\n\n"\
+ "Launch the importation a configured import.\n"\
+ "<command> must be: \"analyse\", \"import\" or \"archive\"."
+
+ def handle(self, *args, **options):
+ if not args or len(args) < 2:
+ raise CommandError("<command> and <import_id> are mandatory")
+ command = args[0]
+ if args[0] not in ["analyse", "import", "archive"]:
+ raise CommandError(
+ "<command> must be: \"analyse\", \"import\" or \"archive\"."
+ )
+ try:
+ imp = models.Import.objects.get(pk=args[1])
+ except (ValueError, models.Import.DoesNotExist):
+ raise CommandError("{} is not a valid import ID".format(args[0]))
+ if command == 'analyse':
+ imp.initialize()
+ self.stdout.write("* {} analysed\n".format(imp))
+ self.stdout.flush()
+ elif command == 'import':
+ self.stdout.write("* import {}\n".format(imp))
+ imp.importation()
+ self.stdout.write("* {} imported\n".format(imp))
+ self.stdout.flush()
+ elif command == 'archive':
+ imp.archive()
+ self.stdout.write("*{} archived\n".format(imp))
+ self.stdout.flush()
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 20b8a6f46..af1c70dce 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -1539,7 +1539,8 @@ TARGET_MODELS = [
('archaeological_finds.models.PreservationType', _(u"Preservation type")),
('archaeological_finds.models.ObjectType', _(u"Object type")),
('archaeological_context_records.models.IdentificationType',
- _("Identification type"))
+ _("Identification type")),
+ ('SupportType', _(u"Support type")),
]
TARGET_MODELS_KEYS = [tm[0] for tm in TARGET_MODELS]
@@ -1690,8 +1691,8 @@ class Import(models.Model):
verbose_name_plural = _(u"Imports")
def __unicode__(self):
- return u"%s - %s" % (unicode(self.importer_type),
- unicode(self.user))
+ return u"%s - %s - %d" % (unicode(self.importer_type),
+ unicode(self.user), self.pk)
def need_matching(self):
return bool(TargetKey.objects.filter(associated_import=self,
@@ -2150,14 +2151,15 @@ class Source(models.Model):
creation_date = models.DateField(blank=True, null=True,
verbose_name=_(u"Creation date"))
item_number = models.IntegerField(_(u"Item number"), default=1)
- reference = models.CharField(_(u"Ref."), max_length=25, null=True,
+ reference = models.CharField(_(u"Ref."), max_length=100, null=True,
blank=True)
- internal_reference = models.CharField(_(u"Internal reference"),
- max_length=25, null=True, blank=True)
+ internal_reference = models.CharField(
+ _(u"Internal ref."), max_length=100, null=True, blank=True)
description = models.TextField(_(u"Description"), blank=True, null=True)
comment = models.TextField(_(u"Comment"), blank=True, null=True)
additional_information = models.TextField(_(u"Additional information"),
blank=True, null=True)
+ duplicate = models.BooleanField(_(u"Has a duplicate"), default=False)
TABLE_COLS = ['title', 'source_type', 'authors', ]
class Meta:
@@ -2166,6 +2168,13 @@ class Source(models.Model):
def __unicode__(self):
return self.title
+ @property
+ def associated_filename(self):
+ values = [unicode(getattr(self, attr))
+ for attr in ('source_type', 'title')
+ if getattr(self, attr)]
+ return slugify(u"-".join(values))
+
if settings.COUNTRY == 'fr':
class Arrondissement(models.Model):
name = models.CharField(u"Nom", max_length=30)
diff --git a/ishtar_common/templates/blocks/JQueryJqGrid.html b/ishtar_common/templates/blocks/JQueryJqGrid.html
index 7e7086738..e8647dadf 100644
--- a/ishtar_common/templates/blocks/JQueryJqGrid.html
+++ b/ishtar_common/templates/blocks/JQueryJqGrid.html
@@ -73,6 +73,7 @@ jQuery(document).ready(function(){
{name:'link', index:'link', width:30},
{{extra_cols|safe}}
],
+ height: 300,
sortname: 'value',
viewrecords: true,
sortorder: "asc",
diff --git a/ishtar_common/templates/blocks/inline_formset.html b/ishtar_common/templates/blocks/inline_formset.html
index 3affb7bf3..4d4042985 100644
--- a/ishtar_common/templates/blocks/inline_formset.html
+++ b/ishtar_common/templates/blocks/inline_formset.html
@@ -12,7 +12,7 @@
{% if frm.errors %}<tr><td colspan='3'><ul>{% for error in frm.errors.values %}<li>{{error}}</li>{% endfor%}</ul></td></tr>{% endif %}
<tr>{% endif %}{% for field in frm.visible_fields %}<td>
{% if field.errors %}<div class='errors'>{{ field.errors.as_ul }}</div>{% endif %}
- {{ field }}
+ {{ field|safe }}
{# Include the hidden fields in the form #}
{% if forloop.first %}
{{ formset.management_form }}
diff --git a/ishtar_common/templates/ishtar/blocks/window_field_url.html b/ishtar_common/templates/ishtar/blocks/window_field_url.html
new file mode 100644
index 000000000..b91f318b6
--- /dev/null
+++ b/ishtar_common/templates/ishtar/blocks/window_field_url.html
@@ -0,0 +1,3 @@
+{% load i18n %}
+{% if link %}<p><label>{% trans caption %}{% trans ":"%}</label>
+<span class='value'><a target="_blank" href='{{link|safe}}'>{% if link_name %}{{link_name}}{% else %}{% trans "link" %}{% endif %}</a></span></p>{% endif%}
diff --git a/ishtar_common/templates/ishtar/sheet.html b/ishtar_common/templates/ishtar/sheet.html
index 915376938..1302e4637 100644
--- a/ishtar_common/templates/ishtar/sheet.html
+++ b/ishtar_common/templates/ishtar/sheet.html
@@ -45,7 +45,9 @@ jQuery(document).ready(function(){
</script>
{% endblock %}
<div class="body">
-{% block content %}{% endblock %}
+{% block toolbar %}{% endblock %}
+{% block content %}
+{% endblock %}
</div>
</div>
{%block main_foot%}
diff --git a/ishtar_common/templates/ishtar/sheet_source.html b/ishtar_common/templates/ishtar/sheet_source.html
new file mode 100644
index 000000000..47e285017
--- /dev/null
+++ b/ishtar_common/templates/ishtar/sheet_source.html
@@ -0,0 +1,24 @@
+{% extends "ishtar/sheet.html" %}
+{% load i18n window_field link_to_window %}
+{% block toolbar %}{% include "ishtar/sheet_toolbar.html" %}{% endblock %}
+{% block content %}
+{% block general %}
+{% field "Title" item.title %}
+{% field "Source type" item.source_type %}
+{% field "Format type" item.format_type %}
+{% field "Scale" item.scale %}
+{% field_url "Web link" item.associated_url %}
+{% field_multiple "Authors" item.authors %}
+{% field "Item number" item.item_number %}
+{% field "Ref." item.reference %}
+{% field "Internal ref." item.internal_reference %}
+{% field "Has a duplicate" item.duplicate %}
+{% field "Description" item.description %}
+{% field "Comment" item.comment %}
+{% field "Additional information" item.additional_information %}
+{% endblock %}
+{% block related %}
+{% field "Related item" item.owner %}
+{% endblock %}
+{% endblock %}
+
diff --git a/ishtar_common/templates/ishtar/sheet_toolbar.html b/ishtar_common/templates/ishtar/sheet_toolbar.html
new file mode 100644
index 000000000..2e059781e
--- /dev/null
+++ b/ishtar_common/templates/ishtar/sheet_toolbar.html
@@ -0,0 +1,2 @@
+{% load i18n link_to_window %}<div class='tool'>{%trans "Export as:"%} <a href='{{item|link_to_odt}}'>{%trans "OpenOffice.org file"%}</a>, <a href='{{item|link_to_pdf}}'>{%trans "PDF file"%}</a></div>
+
diff --git a/ishtar_common/templates/ishtar/wizard/relations_wizard.html b/ishtar_common/templates/ishtar/wizard/relations_wizard.html
new file mode 100644
index 000000000..9ca592ca8
--- /dev/null
+++ b/ishtar_common/templates/ishtar/wizard/relations_wizard.html
@@ -0,0 +1,32 @@
+{% extends "ishtar/wizard/default_wizard.html" %}
+{% load i18n range inline_formset %}
+{% block extra_head %}
+{{wizard.form.media}}
+{% endblock %}
+{% block wizard_form %}
+<form action="." method="post">{% csrf_token %}
+<div class='form'>
+{{ wizard.form.media }}
+{{ wizard.management_form }}
+{{ wizard.form.management_form }}
+
+{% if wizard.form.non_form_errors%}
+<table class='formset'>
+<tr class='error'><th colspan='2'>{{wizard.form.non_form_errors}}</th></tr>
+</table>{%endif%}
+
+<table class='inline-table'>
+ <tr>{% for field in wizard.form.forms.0 %}<th{% if not forloop.last %} rowspan='2'{% endif %}>{{ field.label_tag }}</th>{% endfor %}</tr>
+ <tr><td>({% trans "all"%} <input type='checkbox' name='check-all' class='check-all'/>)</td></tr>
+ {% inline_formset 'Parcels' wizard.form.forms False %}
+</table>
+<p><button name="formset_modify" value="{{wizard.steps.current}}">{% trans "Add/Modify" %}</button></p>
+<input type="hidden" name="{{ step_field }}" value="{{ step0 }}" />
+{{ previous_fields|safe }}
+{% block "validation_bar" %}
+{% include 'ishtar/wizard/validation_bar.html' %}
+{% endblock %}
+</div>
+</form>
+{% endblock %}
+
diff --git a/ishtar_common/templatetags/inline_formset.py b/ishtar_common/templatetags/inline_formset.py
index c3220f207..5e833c06f 100644
--- a/ishtar_common/templatetags/inline_formset.py
+++ b/ishtar_common/templatetags/inline_formset.py
@@ -2,11 +2,10 @@
# -*- coding: utf-8 -*-
from django import template
-from django.utils.translation import ugettext as _
-import re
register = template.Library()
+
@register.inclusion_tag('blocks/inline_formset.html')
def inline_formset(caption, formset, header=True, skip=False):
u"""
@@ -14,5 +13,5 @@ def inline_formset(caption, formset, header=True, skip=False):
For i18n of the caption be carreful to add manualy the caption label to
the translated fields
"""
- return {'caption':caption, 'formset':formset, 'header':header, 'skip':skip}
-
+ return {'caption': caption, 'formset': formset, 'header': header,
+ 'skip': skip}
diff --git a/ishtar_common/templatetags/link_to_window.py b/ishtar_common/templatetags/link_to_window.py
new file mode 100644
index 000000000..65e8b23ca
--- /dev/null
+++ b/ishtar_common/templatetags/link_to_window.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from django.core.urlresolvers import reverse
+from django.template import Library
+from django.utils.translation import ugettext as _
+
+register = Library()
+
+
+@register.filter
+def link_to_window(item):
+ return u' <a class="display_details" href="#" '\
+ 'onclick="load_window(\'{}\')">{}</a>'.format(
+ reverse(item.SHOW_URL, args=[item.pk, '']),
+ _("Details"))
+
+
+@register.filter
+def link_to_odt(item):
+ return reverse(item.SHOW_URL, args=[item.pk, 'odt'])
+
+
+@register.filter
+def link_to_pdf(item):
+ return reverse(item.SHOW_URL, args=[item.pk, 'pdf'])
diff --git a/ishtar_common/templatetags/window_field.py b/ishtar_common/templatetags/window_field.py
index 4a764166a..34071f60f 100644
--- a/ishtar_common/templatetags/window_field.py
+++ b/ishtar_common/templatetags/window_field.py
@@ -1,14 +1,26 @@
from django import template
+from django.utils.translation import ugettext_lazy as _
register = template.Library()
@register.inclusion_tag('ishtar/blocks/window_field.html')
def field(caption, data, pre_data='', post_data=''):
+ if data in (True, False):
+ data = _(unicode(data))
return {'caption': caption, 'data': data, "pre_data": pre_data,
'post_data': post_data}
+@register.inclusion_tag('ishtar/blocks/window_field_url.html')
+def field_url(caption, link, link_name=''):
+ if not link:
+ return u''
+ if not link.startswith('http://'):
+ link = 'http://' + link
+ return {'caption': caption, 'link': link, "link_name": link_name}
+
+
@register.inclusion_tag('ishtar/blocks/window_field_multiple.html')
def field_multiple(caption, data):
return {'caption': caption, 'data': data}
diff --git a/ishtar_common/views.py b/ishtar_common/views.py
index a18673b44..1320517ff 100644
--- a/ishtar_common/views.py
+++ b/ishtar_common/views.py
@@ -325,18 +325,24 @@ def get_item(model, func_name, default_name, extra_request_keys=[],
# check rights
own = True # more restrictive by default
allowed = False
- for perm, lbl in model._meta.permissions:
- # if not specific any perm is relevant (read right)
- if specific_perms and perm not in specific_perms:
- continue
- if request.user.has_perm(model._meta.app_label + '.' + perm) \
- or (request.user.is_authenticated()
- and request.user.ishtaruser.has_right(
- perm, session=request.session)):
- allowed = True
- if "_own_" not in perm:
- own = False
- break # max right reach
+ if request.user.is_authenticated() and \
+ request.user.ishtaruser.has_right('administrator',
+ session=request.session):
+ allowed = True
+ own = False
+ else:
+ for perm, lbl in model._meta.permissions:
+ # if not specific any perm is relevant (read right)
+ if specific_perms and perm not in specific_perms:
+ continue
+ if request.user.has_perm(model._meta.app_label + '.' + perm) \
+ or (request.user.is_authenticated()
+ and request.user.ishtaruser.has_right(
+ perm, session=request.session)):
+ allowed = True
+ if "_own_" not in perm:
+ own = False
+ break # max right reach
if force_own:
own = True
EMPTY = ''
diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py
index d00766978..031498ca3 100644
--- a/ishtar_common/wizards.py
+++ b/ishtar_common/wizards.py
@@ -326,7 +326,7 @@ class Wizard(NamedUrlWizardView):
for val in values:
item = associated_models[key].objects.get(pk=val)
if hasattr(item, 'short_label'):
- value = item.short_label
+ value = unicode(item.short_label)
else:
value = unicode(item)
rendered_values.append(value)
@@ -545,30 +545,46 @@ class Wizard(NamedUrlWizardView):
# material_index management for baseitems
obj.save()
m2m_items = {}
+ # clear
+ # TODO! perf - to be really optimized
for model in whole_associated_models:
- getattr(obj, model + 's').clear()
+ related_model = getattr(obj, model + 's')
+ # clear real m2m
+ if hasattr(related_model, 'clear'):
+ related_model.clear()
+ else:
+ for r in related_model.all():
+ r.delete()
for key, value in m2m:
+ related_model = getattr(obj, key + 's')
if key not in m2m_items:
if type(key) == dict:
vals = []
- for item in getattr(obj, key + 's').all():
+ for item in related_model.all():
v = {}
for k in value.keys():
v[k] = getattr(item, k)
vals.append(v)
m2m_items[key] = vals
else:
- m2m_items[key] = getattr(obj, key + 's').all()
+ m2m_items[key] = related_model.all()
if value not in m2m_items[key]:
if type(value) == dict:
- model = getattr(obj, key + 's').model
+ 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 that an item is not add multiple times (forged forms)
- if value not in getattr(obj, key + 's').all():
- getattr(obj, key + 's').add(value)
+ if value not in related_model.all() and\
+ hasattr(related_model, 'add'):
+ related_model.add(value)
# necessary to manage interaction between models like
# material_index management for baseitems
obj.save()