summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/forms_common.py98
-rw-r--r--ishtar_common/ishtar_menu.py12
-rw-r--r--ishtar_common/locale/django.pot228
-rw-r--r--ishtar_common/models.py4
-rw-r--r--ishtar_common/static/media/style.css40
-rw-r--r--ishtar_common/templates/blocks/JQueryJqGrid.html4
-rw-r--r--ishtar_common/templates/ishtar/display_item.html11
-rw-r--r--ishtar_common/templates/ishtar/form.html5
-rw-r--r--ishtar_common/urls.py17
-rw-r--r--ishtar_common/views.py77
10 files changed, 387 insertions, 109 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py
index e288745e2..77e9c8972 100644
--- a/ishtar_common/forms_common.py
+++ b/ishtar_common/forms_common.py
@@ -33,6 +33,7 @@ from django.utils.translation import ugettext_lazy as _
import models
import widgets
+from ishtar_common.templatetags.link_to_window import link_to_window
from forms import FinalForm, FormSet, reverse_lazy, name_validator, \
TableSelect, ManageOldType
@@ -228,6 +229,86 @@ class OrganizationFormSelection(forms.Form):
validators=[models.valid_id(models.Organization)])
+class ManualMerge(object):
+ def clean_to_merge(self):
+ value = self.cleaned_data.get('to_merge', None) or []
+ if value:
+ value = value.split(',')
+ values = []
+ for val in value:
+ try:
+ values.append(int(val))
+ except ValueError:
+ pass
+ if len(values) < 2:
+ raise forms.ValidationError(_(u"At leat two items have to be "
+ u"selected."))
+ self.cleaned_data['to_merge'] = values
+ return values
+
+ def get_items(self):
+ items = []
+ model = self.associated_models['to_merge']
+ for pk in sorted(self.cleaned_data['to_merge']):
+ try:
+ items.append(model.objects.get(pk=pk))
+ except model.DoesNotExist:
+ pass
+ return items
+
+
+class MergeIntoForm(forms.Form):
+ main_item = forms.ChoiceField(
+ label=_("Merge all items into"), choices=[],
+ widget=forms.RadioSelect())
+
+ def __init__(self, *args, **kwargs):
+ self.items = kwargs.pop('items')
+ super(MergeIntoForm, self).__init__(*args, **kwargs)
+ self.fields['main_item'].choices = []
+ for pk in self.items:
+ try:
+ item = self.associated_model.objects.get(pk=pk)
+ except self.associated_model.DoesNotExist:
+ continue
+ self.fields['main_item'].choices.append(
+ (item.pk, mark_safe(u"{} {}".format(link_to_window(item),
+ unicode(item)))))
+
+ def merge(self):
+ model = self.associated_model
+ try:
+ main_item = model.objects.get(pk=self.cleaned_data['main_item'])
+ except model.DoesNotExist:
+ return
+ for pk in self.items:
+ if pk == unicode(main_item.pk):
+ continue
+ try:
+ item = model.objects.get(pk=pk)
+ except model.DoesNotExist:
+ continue
+ main_item.merge(item)
+ return main_item
+
+
+class OrgaMergeFormSelection(ManualMerge, forms.Form):
+ form_label = _(u"Organization to merge")
+ associated_models = {'to_merge': models.Organization}
+ currents = {'to_merge': models.Organization}
+ to_merge = forms.CharField(
+ label="", required=False,
+ widget=widgets.JQueryJqGrid(
+ reverse_lazy('get-organization'), OrganizationSelect,
+ models.Organization,
+ multiple_select=True,
+ source_full=reverse_lazy('get-organization-full')),)
+
+
+class OrgaMergeIntoForm(MergeIntoForm):
+ associated_model = models.Organization
+
+
class BaseOrganizationForm(forms.ModelForm):
form_prefix = "orga"
@@ -266,6 +347,23 @@ class PersonFormSelection(forms.Form):
validators=[models.valid_id(models.Person)])
+class PersonMergeFormSelection(ManualMerge, forms.Form):
+ form_label = _("Person to merge")
+ associated_models = {'to_merge': models.Person}
+ currents = {'to_merge': models.Person}
+ to_merge = forms.CharField(
+ label="", required=False,
+ widget=widgets.JQueryJqGrid(
+ reverse_lazy('get-person'),
+ PersonSelect, models.Person,
+ multiple_select=True,
+ source_full=reverse_lazy('get-person-full')),)
+
+
+class PersonMergeIntoForm(MergeIntoForm):
+ associated_model = models.Person
+
+
class SimplePersonForm(ManageOldType, NewItemForm):
form_label = _("Identity")
associated_models = {'attached_to': models.Organization,
diff --git a/ishtar_common/ishtar_menu.py b/ishtar_common/ishtar_menu.py
index 39bf7c1d6..1f30bec0f 100644
--- a/ishtar_common/ishtar_menu.py
+++ b/ishtar_common/ishtar_menu.py
@@ -59,7 +59,11 @@ MENU_SECTIONS = [
model=models.Person,
access_controls=['change_person', 'change_own_person']),
MenuItem(
- 'person_merge', _(u"Merge"),
+ 'person-merge', _(u"Automatic merge"),
+ model=models.Person,
+ access_controls=['merge_person']),
+ MenuItem(
+ 'person-manual-merge', _(u"Manual merge"),
model=models.Person,
access_controls=['merge_person']),
MenuItem(
@@ -86,7 +90,11 @@ MENU_SECTIONS = [
access_controls=['change_organization',
'change_own_organization']),
MenuItem(
- 'organization_merge', _(u"Merge"),
+ 'organization-merge', _(u"Automatic merge"),
+ model=models.Organization,
+ access_controls=['merge_organization']),
+ MenuItem(
+ 'orga-manual-merge', _(u"Manual merge"),
model=models.Organization,
access_controls=['merge_organization']),
MenuItem(
diff --git a/ishtar_common/locale/django.pot b/ishtar_common/locale/django.pot
index 7d64d9d63..9ec7eb939 100644
--- a/ishtar_common/locale/django.pot
+++ b/ishtar_common/locale/django.pot
@@ -131,7 +131,7 @@ msgstr ""
msgid "Enter a valid name consisting of letters, spaces and hyphens."
msgstr ""
-#: forms.py:71 forms_common.py:520
+#: forms.py:71 forms_common.py:618
msgid "Confirm"
msgstr ""
@@ -159,14 +159,14 @@ msgstr ""
msgid "Template"
msgstr ""
-#: forms_common.py:40 forms_common.py:58 forms_common.py:181
-#: forms_common.py:308 models.py:1344 models.py:2658
+#: forms_common.py:41 forms_common.py:59 forms_common.py:182
+#: forms_common.py:406 models.py:1344 models.py:2658
#: templates/blocks/JQueryAdvancedTown.html:19
#: templates/ishtar/sheet_organization.html:13
msgid "Town"
msgstr ""
-#: forms_common.py:42
+#: forms_common.py:43
msgid ""
"<p>Type name, department code and/or postal code of the town you would like "
"to select. The search is insensitive to case.</p>\n"
@@ -176,75 +176,75 @@ msgid ""
"french town Saint-Denis in the Seine-Saint-Denis department.</p>"
msgstr ""
-#: forms_common.py:67 forms_common.py:757 ishtar_menu.py:47 models.py:1512
+#: forms_common.py:68 forms_common.py:855 ishtar_menu.py:47 models.py:1512
#: models.py:2326 models.py:2480 models.py:2538
#: templates/ishtar/sheet_person.html:4
msgid "Person"
msgstr ""
-#: forms_common.py:116
+#: forms_common.py:117
msgid ""
"This import type have no unicity type defined. Conservative import is not "
"possible."
msgstr ""
-#: forms_common.py:169 forms_common.py:246 forms_common.py:353
-#: ishtar_menu.py:71 models.py:1513 models.py:2231
+#: forms_common.py:170 forms_common.py:327 forms_common.py:451
+#: ishtar_menu.py:75 models.py:1513 models.py:2231
#: templates/ishtar/sheet_organization.html:4
msgid "Organization"
msgstr ""
-#: forms_common.py:172 forms_common.py:209 forms_common.py:241
-#: forms_common.py:278 forms_common.py:348 models.py:945 models.py:1277
+#: forms_common.py:173 forms_common.py:210 forms_common.py:322
+#: forms_common.py:376 forms_common.py:446 models.py:945 models.py:1277
#: models.py:1558 models.py:1776 models.py:2225 models.py:2312 models.py:2644
#: templates/ishtar/sheet_organization.html:8
#: templates/ishtar/sheet_organization.html:21
msgid "Name"
msgstr ""
-#: forms_common.py:173 models.py:1499 models.py:1907
+#: forms_common.py:174 models.py:1499 models.py:1907
msgid "Organization type"
msgstr ""
-#: forms_common.py:175 forms_common.py:302 models.py:1339
+#: forms_common.py:176 forms_common.py:400 models.py:1339
#: templates/ishtar/sheet_organization.html:10
msgid "Address"
msgstr ""
-#: forms_common.py:177 forms_common.py:305 models.py:1340
+#: forms_common.py:178 forms_common.py:403 models.py:1340
#: templates/ishtar/sheet_organization.html:11
msgid "Address complement"
msgstr ""
-#: forms_common.py:179 forms_common.py:306 models.py:1342
+#: forms_common.py:180 forms_common.py:404 models.py:1342
#: templates/ishtar/sheet_organization.html:12
msgid "Postal code"
msgstr ""
-#: forms_common.py:182 forms_common.py:309 models.py:1345
+#: forms_common.py:183 forms_common.py:407 models.py:1345
msgid "Country"
msgstr ""
-#: forms_common.py:184 forms_common.py:243 forms_common.py:282
-#: forms_common.py:350 forms_common.py:474 models.py:1372
+#: forms_common.py:185 forms_common.py:324 forms_common.py:380
+#: forms_common.py:448 forms_common.py:572 models.py:1372
msgid "Email"
msgstr ""
-#: forms_common.py:185 forms_common.py:285 models.py:1357
+#: forms_common.py:186 forms_common.py:383 models.py:1357
#: templates/ishtar/sheet_organization.html:14
#: templates/ishtar/sheet_person.html:19
#: templates/ishtar/wizard/wizard_person.html:17
msgid "Phone"
msgstr ""
-#: forms_common.py:186 forms_common.py:294 models.py:1369
+#: forms_common.py:187 forms_common.py:392 models.py:1369
#: templates/ishtar/sheet_organization.html:15
#: templates/ishtar/sheet_person.html:37
#: templates/ishtar/wizard/wizard_person.html:35
msgid "Mobile phone"
msgstr ""
-#: forms_common.py:210 forms_common.py:244 forms_common.py:351 models.py:1935
+#: forms_common.py:211 forms_common.py:325 forms_common.py:449 models.py:1935
#: models.py:2227 models.py:2579 templates/sheet_ope.html:85
#: templates/sheet_ope.html.py:105 templates/sheet_ope.html:126
#: templates/ishtar/import_list.html:13
@@ -253,225 +253,241 @@ msgstr ""
msgid "Type"
msgstr ""
-#: forms_common.py:219 views.py:137
+#: forms_common.py:220 views.py:137
msgid "Organization search"
msgstr ""
-#: forms_common.py:242 forms_common.py:276 forms_common.py:349 models.py:2310
+#: forms_common.py:244
+msgid "At leat two items have to be selected."
+msgstr ""
+
+#: forms_common.py:262
+msgid "Merge all items into"
+msgstr ""
+
+#: forms_common.py:296
+msgid "Organization to merge"
+msgstr ""
+
+#: forms_common.py:323 forms_common.py:374 forms_common.py:447 models.py:2310
#: templates/ishtar/sheet_organization.html:22
msgid "Surname"
msgstr ""
-#: forms_common.py:258 forms_common.py:336 views.py:102
+#: forms_common.py:339 forms_common.py:434 views.py:102
msgid "Person search"
msgstr ""
-#: forms_common.py:270 templates/ishtar/sheet_person.html:7
+#: forms_common.py:351
+msgid "Person to merge"
+msgstr ""
+
+#: forms_common.py:368 templates/ishtar/sheet_person.html:7
#: templates/ishtar/wizard/wizard_person.html:6
msgid "Identity"
msgstr ""
-#: forms_common.py:273 forms_common.py:675 forms_common.py:724 models.py:1908
+#: forms_common.py:371 forms_common.py:773 forms_common.py:822 models.py:1908
#: models.py:2304 models.py:2306 models.py:2576 templates/sheet_ope.html:104
#: templates/ishtar/blocks/window_tables/documents.html:7
msgid "Title"
msgstr ""
-#: forms_common.py:274 models.py:2308
+#: forms_common.py:372 models.py:2308
msgid "Salutation"
msgstr ""
-#: forms_common.py:280 models.py:2314
+#: forms_common.py:378 models.py:2314
msgid "Raw name"
msgstr ""
-#: forms_common.py:283 models.py:1358
+#: forms_common.py:381 models.py:1358
msgid "Phone description"
msgstr ""
-#: forms_common.py:286 models.py:1360 models.py:1362
+#: forms_common.py:384 models.py:1360 models.py:1362
msgid "Phone description 2"
msgstr ""
-#: forms_common.py:288
+#: forms_common.py:386
msgid "Phone 2"
msgstr ""
-#: forms_common.py:290 models.py:1366
+#: forms_common.py:388 models.py:1366
msgid "Phone description 3"
msgstr ""
-#: forms_common.py:292 models.py:1364
+#: forms_common.py:390 models.py:1364
msgid "Phone 3"
msgstr ""
-#: forms_common.py:297
+#: forms_common.py:395
msgid "Current organization"
msgstr ""
-#: forms_common.py:311 models.py:1347
+#: forms_common.py:409 models.py:1347
msgid "Other address: address"
msgstr ""
-#: forms_common.py:314 models.py:1350
+#: forms_common.py:412 models.py:1350
msgid "Other address: address complement"
msgstr ""
-#: forms_common.py:316 models.py:1351
+#: forms_common.py:414 models.py:1351
msgid "Other address: postal code"
msgstr ""
-#: forms_common.py:318 models.py:1353
+#: forms_common.py:416 models.py:1353
msgid "Other address: town"
msgstr ""
-#: forms_common.py:320 models.py:1355
+#: forms_common.py:418 models.py:1355
msgid "Other address: country"
msgstr ""
-#: forms_common.py:332
+#: forms_common.py:430
msgid "Already has an account"
msgstr ""
-#: forms_common.py:347
+#: forms_common.py:445
msgid "Username"
msgstr ""
-#: forms_common.py:365
+#: forms_common.py:463
msgid "Account search"
msgstr ""
-#: forms_common.py:412 forms_common.py:452 forms_common.py:456 models.py:2279
+#: forms_common.py:510 forms_common.py:550 forms_common.py:554 models.py:2279
msgid "Person type"
msgstr ""
-#: forms_common.py:468 forms_common.py:473 ishtar_menu.py:32
+#: forms_common.py:566 forms_common.py:571 ishtar_menu.py:32
msgid "Account"
msgstr ""
-#: forms_common.py:477 wizards.py:1192
+#: forms_common.py:575 wizards.py:1192
msgid "New password"
msgstr ""
-#: forms_common.py:480
+#: forms_common.py:578
msgid "New password (confirmation)"
msgstr ""
-#: forms_common.py:501
+#: forms_common.py:599
msgid "Your password and confirmation password do not match."
msgstr ""
-#: forms_common.py:506
+#: forms_common.py:604
msgid "You must provide a correct password."
msgstr ""
-#: forms_common.py:514
+#: forms_common.py:612
msgid "This username already exists."
msgstr ""
-#: forms_common.py:521
+#: forms_common.py:619
msgid "Send the new password by email?"
msgstr ""
-#: forms_common.py:530 forms_common.py:543 models.py:2659
+#: forms_common.py:628 forms_common.py:641 models.py:2659
msgid "Towns"
msgstr ""
-#: forms_common.py:540
+#: forms_common.py:638
msgid "There are identical towns."
msgstr ""
-#: forms_common.py:624
+#: forms_common.py:722
msgid "Only one choice can be checked."
msgstr ""
-#: forms_common.py:672
+#: forms_common.py:770
msgid "Documentation informations"
msgstr ""
-#: forms_common.py:677 forms_common.py:725 models.py:1909 models.py:2559
+#: forms_common.py:775 forms_common.py:823 models.py:1909 models.py:2559
msgid "Source type"
msgstr ""
-#: forms_common.py:679 forms_common.py:726 templates/sheet_ope.html:84
+#: forms_common.py:777 forms_common.py:824 templates/sheet_ope.html:84
msgid "Reference"
msgstr ""
-#: forms_common.py:682 forms_common.py:727
+#: forms_common.py:780 forms_common.py:825
msgid "Internal reference"
msgstr ""
-#: forms_common.py:685 models.py:2590
+#: forms_common.py:783 models.py:2590
msgid "Numerical ressource (web address)"
msgstr ""
-#: forms_common.py:686 models.py:2592
+#: forms_common.py:784 models.py:2592
msgid "Receipt date"
msgstr ""
-#: forms_common.py:688 models.py:2062 models.py:2594
+#: forms_common.py:786 models.py:2062 models.py:2594
msgid "Creation date"
msgstr ""
-#: forms_common.py:691 models.py:2597
+#: forms_common.py:789 models.py:2597
msgid "Receipt date in documentation"
msgstr ""
-#: forms_common.py:693 forms_common.py:729 models.py:289 models.py:548
+#: forms_common.py:791 forms_common.py:827 models.py:289 models.py:548
#: models.py:1803 models.py:2318 models.py:2604
msgid "Comment"
msgstr ""
-#: forms_common.py:695 forms_common.py:728 models.py:947 models.py:1562
+#: forms_common.py:793 forms_common.py:826 models.py:947 models.py:1562
#: models.py:1735 models.py:1777 models.py:2603 templates/sheet_ope.html:128
msgid "Description"
msgstr ""
-#: forms_common.py:698 models.py:2605
+#: forms_common.py:796 models.py:2605
msgid "Additional information"
msgstr ""
-#: forms_common.py:700 forms_common.py:732 models.py:2607
+#: forms_common.py:798 forms_common.py:830 models.py:2607
msgid "Has a duplicate"
msgstr ""
-#: forms_common.py:703
+#: forms_common.py:801
msgid "Image"
msgstr ""
-#: forms_common.py:704
+#: forms_common.py:802
#, python-format
msgid ""
"<p>Heavy images are resized to: %(width)dx%(height)d (ratio is preserved).</"
"p>"
msgstr ""
-#: forms_common.py:721 forms_common.py:750 forms_common.py:784 models.py:2543
+#: forms_common.py:819 forms_common.py:848 forms_common.py:882 models.py:2543
#: templates/ishtar/wizard/wizard_person_deletion.html:124
msgid "Author"
msgstr ""
-#: forms_common.py:731
+#: forms_common.py:829
msgid "Additional informations"
msgstr ""
-#: forms_common.py:742
+#: forms_common.py:840
msgid "Would you like to delete this documentation?"
msgstr ""
-#: forms_common.py:758 models.py:1910 models.py:2533 models.py:2540
+#: forms_common.py:856 models.py:1910 models.py:2533 models.py:2540
msgid "Author type"
msgstr ""
-#: forms_common.py:777
+#: forms_common.py:875
msgid "Author selection"
msgstr ""
-#: forms_common.py:791
+#: forms_common.py:889
msgid "There are identical authors."
msgstr ""
-#: forms_common.py:795 models.py:2544 models.py:2586
+#: forms_common.py:893 models.py:2544 models.py:2586
#: templates/sheet_ope.html:106
#: templates/ishtar/blocks/window_tables/documents.html:9
msgid "Authors"
@@ -489,7 +505,7 @@ msgstr ""
msgid "Deletion"
msgstr ""
-#: ishtar_menu.py:39 models.py:1073 views.py:1365
+#: ishtar_menu.py:39 models.py:1073 views.py:1377
msgid "Global variables"
msgstr ""
@@ -497,40 +513,44 @@ msgstr ""
msgid "Directory"
msgstr ""
-#: ishtar_menu.py:50 ishtar_menu.py:74 templates/blocks/JQueryJqGrid.html:3
+#: ishtar_menu.py:50 ishtar_menu.py:78 templates/blocks/JQueryJqGrid.html:3
msgid "Search"
msgstr ""
-#: ishtar_menu.py:54 ishtar_menu.py:79 templates/ishtar/import_list.html:15
+#: ishtar_menu.py:54 ishtar_menu.py:83 templates/ishtar/import_list.html:15
msgid "Creation"
msgstr ""
-#: ishtar_menu.py:58 ishtar_menu.py:84
+#: ishtar_menu.py:58 ishtar_menu.py:88
msgid "Modification"
msgstr ""
-#: ishtar_menu.py:62 ishtar_menu.py:89 templates/ishtar/merge.html:5
-msgid "Merge"
+#: ishtar_menu.py:62 ishtar_menu.py:93
+msgid "Automatic merge"
+msgstr ""
+
+#: ishtar_menu.py:66 ishtar_menu.py:97
+msgid "Manual merge"
msgstr ""
-#: ishtar_menu.py:66 ishtar_menu.py:93 models.py:2099 widgets.py:110
+#: ishtar_menu.py:70 ishtar_menu.py:101 models.py:2099 widgets.py:110
#: templates/ishtar/form_delete.html:11
msgid "Delete"
msgstr ""
-#: ishtar_menu.py:101 models.py:2073
+#: ishtar_menu.py:109 models.py:2073
msgid "Imports"
msgstr ""
-#: ishtar_menu.py:104 views.py:1373
+#: ishtar_menu.py:112 views.py:1385
msgid "New import"
msgstr ""
-#: ishtar_menu.py:108 views.py:1387
+#: ishtar_menu.py:116 views.py:1399
msgid "Current imports"
msgstr ""
-#: ishtar_menu.py:112
+#: ishtar_menu.py:120
msgid "Old imports"
msgstr ""
@@ -819,11 +839,11 @@ msgstr ""
msgid "Operation source"
msgstr ""
-#: models.py:1522 views.py:1190 views.py:1241
+#: models.py:1522 views.py:1192 views.py:1243
msgid "Archaeological files"
msgstr ""
-#: models.py:1524 views.py:1193 views.py:1249
+#: models.py:1524 views.py:1195 views.py:1251
msgid "Context records"
msgstr ""
@@ -831,7 +851,7 @@ msgstr ""
msgid "Context record relations"
msgstr ""
-#: models.py:1528 views.py:1195 views.py:1252
+#: models.py:1528 views.py:1197 views.py:1254
msgid "Finds"
msgstr ""
@@ -1389,28 +1409,44 @@ msgstr ""
msgid "Find"
msgstr ""
-#: views.py:1103 views.py:1172
+#: views.py:1105 views.py:1174
msgid "Operation not permitted."
msgstr ""
-#: views.py:1105
+#: views.py:1107
#, python-format
msgid "New %s"
msgstr ""
-#: views.py:1191 views.py:1245
+#: views.py:1193 views.py:1247
msgid "Operations"
msgstr ""
-#: views.py:1434 templates/ishtar/import_list.html:43
+#: views.py:1446 templates/ishtar/import_list.html:43
msgid "Link unmatched items"
msgstr ""
-#: views.py:1449
+#: views.py:1461
msgid "Delete import"
msgstr ""
-#: views.py:1508 views.py:1524
+#: views.py:1500
+msgid "Merge persons"
+msgstr ""
+
+#: views.py:1524
+msgid "Select the main person"
+msgstr ""
+
+#: views.py:1533
+msgid "Merge organization"
+msgstr ""
+
+#: views.py:1543
+msgid "Select the main organization"
+msgstr ""
+
+#: views.py:1583 views.py:1599
msgid "Corporation manager"
msgstr ""
@@ -1870,7 +1906,7 @@ msgstr ""
msgid "remove"
msgstr ""
-#: templates/ishtar/form.html:10 templates/ishtar/formset.html:8
+#: templates/ishtar/form.html:11 templates/ishtar/formset.html:8
#: templates/ishtar/import_list.html:58 templates/ishtar/merge.html:31
#: templates/ishtar/simple_form.html:7
#: templates/ishtar/wizard/confirm_wizard.html:42
@@ -1929,6 +1965,10 @@ msgstr ""
msgid "Basket content"
msgstr ""
+#: templates/ishtar/merge.html:5
+msgid "Merge"
+msgstr ""
+
#: templates/ishtar/merge.html:7
msgid "Every operation on this form is irreversible"
msgstr ""
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index f3f9f0778..9ec03b60e 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -2220,7 +2220,7 @@ pre_delete.connect(pre_delete_import, sender=Import)
class Organization(Address, Merge, OwnPerms, ValueGetter):
- TABLE_COLS = ('name', 'organization_type',)
+ TABLE_COLS = ('name', 'organization_type', 'town')
SHOW_URL = 'show-organization'
name = models.CharField(_(u"Name"), max_length=500)
organization_type = models.ForeignKey(OrganizationType,
@@ -2298,7 +2298,7 @@ class Person(Address, Merge, OwnPerms, ValueGetter):
('Dr', _(u'Doctor')),
)
TABLE_COLS = ('name', 'surname', 'raw_name', 'email', 'person_types_list',
- 'attached_to')
+ 'attached_to', 'town')
SHOW_URL = 'show-person'
MODIFY_URL = 'person_modify'
old_title = models.CharField(_(u"Title"), max_length=100, choices=TYPE,
diff --git a/ishtar_common/static/media/style.css b/ishtar_common/static/media/style.css
index bff3ef473..aab5063e4 100644
--- a/ishtar_common/static/media/style.css
+++ b/ishtar_common/static/media/style.css
@@ -886,14 +886,47 @@ a.photo{
padding:0;
}
+.dashboard{
+ margin-top: 1em;
+}
+
+.dashboard.ui-accordion .ui-accordion-header{
+ margin-left: auto;
+ margin-right: auto;
+ padding-top: 0.8em;
+ padding-bottom: 0.8em;
+}
+
+.dashboard.ui-accordion .ui-accordion-content{
+ padding: 1.3em;
+}
+
+.dashboard .ui-icon,
+.dashboard .ui-state-hover .ui-icon,
+.dashboard .ui-state-default .ui-icon,
+.dashboard .ui-state-active .ui-icon {
+ background-image: none;
+ color: white;
+ text-indent: 0;
+}
+
+.dashboard .ui-state-active .ui-icon:before {
+ content: "\f0d7";
+ font-family: 'FontAwesome';
+}
+
+.dashboard .ui-icon:before {
+ content: "\f0da";
+ font-family: 'FontAwesome';
+}
+
.dashboard > div,
.dashboard h3{
width:760px;
margin:0;
margin-left:auto;
margin-right:auto;
- border-radius: 8px;
- border-radius: 8px;
+ border-radius: 4px;
}
.dashboard > div{
@@ -907,12 +940,9 @@ a.photo{
.dashboard h3{
margin-top:1em;
- width:762px;
background-color:#922;
color:#FFF;
padding:10px;
- border-bottom-left-radius: 0;
- border-bottom-right-radius: 0;
}
.dashboard p{
diff --git a/ishtar_common/templates/blocks/JQueryJqGrid.html b/ishtar_common/templates/blocks/JQueryJqGrid.html
index 44f4b0ba8..5972208ee 100644
--- a/ishtar_common/templates/blocks/JQueryJqGrid.html
+++ b/ishtar_common/templates/blocks/JQueryJqGrid.html
@@ -133,7 +133,11 @@ jQuery(document).ready(function(){
{% else %}
jQuery("#submit_form").click(function (){
var mygrid = jQuery("#grid_{{name}}");
+ {% if multiple_select %}
+ jQuery("#hidden_{{name}}").val(mygrid.getGridParam('selarrrow'));
+ {% else %}
jQuery("#hidden_{{name}}").val(mygrid.getGridParam('selrow'));
+ {% endif %}
return true;
});
{% endif %}
diff --git a/ishtar_common/templates/ishtar/display_item.html b/ishtar_common/templates/ishtar/display_item.html
new file mode 100644
index 000000000..87dda6dcf
--- /dev/null
+++ b/ishtar_common/templates/ishtar/display_item.html
@@ -0,0 +1,11 @@
+{% extends "base.html" %}
+{% load i18n %}
+{% load url from future %}
+{% block content %}
+<h2>{{page_name}}</h2>
+<script type='text/javascript'>
+$(function() {
+ load_window("{% url item_url pk %}");
+});
+</script>
+{% endblock %}
diff --git a/ishtar_common/templates/ishtar/form.html b/ishtar_common/templates/ishtar/form.html
index 1e795c540..539bd0408 100644
--- a/ishtar_common/templates/ishtar/form.html
+++ b/ishtar_common/templates/ishtar/form.html
@@ -3,11 +3,12 @@
{% block content %}
<h2>{{page_name}}</h2>
<div class='form'>
-<form enctype="multipart/form-data" action="." method="post">{% csrf_token %}
+<form enctype="multipart/form-data" action="." method="post"{% if confirm %}
+ onsubmit='return confirm("{{confirm}}");'{% endif %}>{% csrf_token %}
<table>
{{form}}
</table>
-<input type="submit" value="{% trans "Validate" %}"/>
+<input id="submit_form" type="submit" value="{% if submit_label %}{{submit_label}}{% else%}{% trans "Validate" %}{% endif %}"/>
</form>
</div>
{% endblock %}
diff --git a/ishtar_common/urls.py b/ishtar_common/urls.py
index 049bcaf7b..27078dd9e 100644
--- a/ishtar_common/urls.py
+++ b/ishtar_common/urls.py
@@ -35,6 +35,8 @@ urlpatterns = patterns(
url(r'^i18n/', include('django.conf.urls.i18n')),
# General
url(r'shortcut_menu/', views.shortcut_menu, name='shortcut-menu'),
+ url(r'display/(?P<item_type>\w+)/(?P<pk>\d+)/',
+ views.DisplayItemView.as_view(), name='display-item'),
url(r'person_search/(?P<step>.+)?$',
check_rights(['add_person'])(
views.person_search_wizard), name='person_search'),
@@ -174,10 +176,21 @@ urlpatterns += patterns(
'autocomplete_organization', name='autocomplete-organization'),
url(r'admin-globalvar/', views.GlobalVarEdit.as_view(),
name='admin-globalvar'),
- url(r'person_merge/(?:(?P<page>\d+)/)?$', 'person_merge',
+ url(r'person-merge/(?:(?P<page>\d+)/)?$', 'person_merge',
name='person_merge'),
- url(r'organization_merge/(?:(?P<page>\d+)/)?$', 'organization_merge',
+ url(r'person-manual-merge/$',
+ views.PersonManualMerge.as_view(),
+ name='person_manual_merge'),
+ url(r'person-manual-merge-items/(?P<pks>[0-9_]+?)/$',
+ views.PersonManualMergeItems.as_view(),
+ name='person_manual_merge_items'),
+ url(r'organization-merge/(?:(?P<page>\d+)/)?$', 'organization_merge',
name='organization_merge'),
+ url(r'orga-manual-merge/$', views.OrgaManualMerge.as_view(),
+ name='orga_manual_merge'),
+ url(r'orga-manual-merge-items/(?P<pks>[0-9_]+?)/$',
+ views.OrgaManualMergeItems.as_view(),
+ name='orga_manual_merge_items'),
url(r'reset/$', 'reset_wizards', name='reset_wizards'),
url(r'(?P<action_slug>' + actions + r')/$', 'action', name='action'),
)
diff --git a/ishtar_common/views.py b/ishtar_common/views.py
index d55181067..5f3e80c77 100644
--- a/ishtar_common/views.py
+++ b/ishtar_common/views.py
@@ -47,8 +47,8 @@ from django.shortcuts import render_to_response, redirect
from django.template import RequestContext, loader
from django.utils.decorators import method_decorator
from django.utils.translation import ugettext, ugettext_lazy as _
-from django.views.generic import ListView, UpdateView
-from django.views.generic.edit import CreateView, DeleteView
+from django.views.generic import ListView, UpdateView, TemplateView
+from django.views.generic.edit import CreateView, DeleteView, FormView
from xhtml2odt import xhtml2odt
@@ -1359,6 +1359,16 @@ class AdminLoginRequiredMixin(LoginRequiredMixin):
request, *args, **kwargs)
+class DisplayItemView(IshtarMixin, LoginRequiredMixin, TemplateView):
+ template_name = 'ishtar/display_item.html'
+
+ def get_context_data(self, *args, **kwargs):
+ data = super(DisplayItemView, self).get_context_data(*args, **kwargs)
+ data['pk'] = unicode(kwargs.get('pk')) + '/'
+ data['item_url'] = 'show-' + kwargs.get('item_type')
+ return data
+
+
class GlobalVarEdit(IshtarMixin, AdminLoginRequiredMixin, ModelFormSetView):
template_name = 'ishtar/formset.html'
model = models.GlobalVar
@@ -1472,6 +1482,69 @@ class PersonEdit(LoginRequiredMixin, UpdateView):
return reverse('person_edit', args=[self.object.pk])
+class ManualMergeMixin(object):
+ def form_valid(self, form):
+ self.items = form.get_items()
+ return super(ManualMergeMixin, self).form_valid(form)
+
+ def get_success_url(self):
+ return reverse(
+ self.redir_url,
+ args=[u"_".join([str(item.pk) for item in self.items])])
+
+
+class PersonManualMerge(ManualMergeMixin, IshtarMixin, LoginRequiredMixin,
+ FormView):
+ form_class = forms.PersonMergeFormSelection
+ template_name = 'ishtar/form.html'
+ page_name = _(u"Merge persons")
+ current_url = 'person-manual-merge'
+ redir_url = 'person_manual_merge_items'
+
+
+class ManualMergeItemsMixin(object):
+ def get_form_kwargs(self):
+ kwargs = super(ManualMergeItemsMixin, self).get_form_kwargs()
+ kwargs['items'] = self.kwargs['pks'].split('_')
+ return kwargs
+
+ def form_valid(self, form):
+ self.item = form.merge()
+ return super(ManualMergeItemsMixin, self).form_valid(form)
+
+ def get_success_url(self):
+ return reverse('display-item', args=[self.item_type, self.item.pk])
+
+
+class PersonManualMergeItems(
+ ManualMergeItemsMixin, IshtarMixin,
+ LoginRequiredMixin, FormView):
+ form_class = forms.PersonMergeIntoForm
+ template_name = 'ishtar/form.html'
+ page_name = _(u"Select the main person")
+ current_url = 'person-manual-merge-items'
+ item_type = 'person'
+
+
+class OrgaManualMerge(ManualMergeMixin, IshtarMixin, LoginRequiredMixin,
+ FormView):
+ form_class = forms.OrgaMergeFormSelection
+ template_name = 'ishtar/form.html'
+ page_name = _(u"Merge organization")
+ current_url = 'orga-manual-merge'
+ redir_url = 'orga_manual_merge_items'
+
+
+class OrgaManualMergeItems(
+ ManualMergeItemsMixin, IshtarMixin,
+ LoginRequiredMixin, FormView):
+ form_class = forms.OrgaMergeIntoForm
+ template_name = 'ishtar/form.html'
+ page_name = _(u"Select the main organization")
+ current_url = 'orga-manual-merge-items'
+ item_type = 'organization'
+
+
class OrganizationCreate(LoginRequiredMixin, CreateView):
model = models.Organization
form_class = forms.BaseOrganizationForm