diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-09-15 00:07:16 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-09-15 00:07:16 +0200 |
commit | df43f19a2f61bffe4fc89baef578dd7ecb0005cc (patch) | |
tree | 880eff06a16fa8537231bab8e79ca9114c68419f | |
parent | f87aa359f5c0dcf7372dca67690fc1baf1178b86 (diff) | |
download | Ishtar-df43f19a2f61bffe4fc89baef578dd7ecb0005cc.tar.bz2 Ishtar-df43f19a2f61bffe4fc89baef578dd7ecb0005cc.zip |
Add QA for orgas and operations
-rw-r--r-- | archaeological_operations/forms.py | 9 | ||||
-rw-r--r-- | ishtar_common/forms_common.py | 26 | ||||
-rw-r--r-- | ishtar_common/models.py | 9 | ||||
-rw-r--r-- | ishtar_common/urls.py | 9 | ||||
-rw-r--r-- | ishtar_common/views.py | 5 |
5 files changed, 54 insertions, 4 deletions
diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index 3c93b945c..8ddd42708 100644 --- a/archaeological_operations/forms.py +++ b/archaeological_operations/forms.py @@ -1806,6 +1806,7 @@ class QAOperationFormMulti(QAForm): base_models = ['qa_operation_type'] associated_models = { 'qa_operation_type': models.OperationType, + 'qa_towns': Town } MULTI = True @@ -1815,8 +1816,16 @@ class QAOperationFormMulti(QAForm): qa_operation_type = forms.ChoiceField( label=_(u"Operation type"), required=False ) + qa_towns = get_town_field(required=False) TYPES = [ FieldType('qa_operation_type', models.OperationType), ] + def _get_qa_towns(self, value): + try: + value = Town.objects.get(pk=value).cached_label + except Town.DoesNotExist: + return "" + return value + diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py index 5eaa6c435..67e29289a 100644 --- a/ishtar_common/forms_common.py +++ b/ishtar_common/forms_common.py @@ -376,7 +376,7 @@ class OrganizationSelect(CustomForm, TableSelect): models.OrganizationType.get_types() -class OrganizationFormSelection(forms.Form): +class OrganizationFormSelection(CustomFormSearch): SEARCH_AND_SELECT = True form_label = _(u"Organization search") associated_models = {'pk': models.Organization} @@ -404,6 +404,27 @@ class OrganizationFormMultiSelection(MultiSearchForm): validators=[models.valid_ids(models.Organization)]) +class QAOrganizationFormMulti(QAForm): + form_admin_name = _(u"Organization - Quick action - Modify") + form_slug = "organization-quickaction-modify" + base_models = ['qa_organization_type'] + associated_models = { + 'qa_organization_type': models.OrganizationType, + } + + MULTI = True + REPLACE_FIELDS = [ + 'qa_organization_type', + ] + qa_organization_type = forms.ChoiceField( + label=_(u"Organization type"), required=False + ) + + TYPES = [ + FieldType('qa_organization_type', models.OrganizationType), + ] + + class ManualMerge(object): def clean_to_merge(self): value = self.cleaned_data.get('to_merge', None) or [] @@ -1421,14 +1442,13 @@ class QADocumentFormMulti(QAForm): ) qa_authors = widgets.ModelJQueryAutocompleteField( model=models.Author, label=_(u"Author"), new=True, - long_widget=True, required=False) + required=False) TYPES = [ FieldType('qa_source_type', models.SourceType), ] def _get_qa_authors(self, value): - print(value) try: value = models.Author.objects.get(pk=value).cached_label except models.Author.DoesNotExist: diff --git a/ishtar_common/models.py b/ishtar_common/models.py index c82837483..66de551da 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -4015,7 +4015,7 @@ organization_type_pk_lazy = lazy(OrganizationType.get_or_create_pk, str) organization_type_pks_lazy = lazy(OrganizationType.get_or_create_pks, str) -class Organization(Address, Merge, OwnPerms, ValueGetter): +class Organization(Address, Merge, OwnPerms, ValueGetter, MainItem): TABLE_COLS = ('name', 'organization_type', 'town') SLUG = "organization" SHOW_URL = 'show-organization' @@ -4037,6 +4037,13 @@ class Organization(Address, Merge, OwnPerms, ValueGetter): 'organization_type__label__iexact' ), } + QA_EDIT = QuickAction( + url="organization-qa-bulk-update", icon_class="fa fa-pencil", + text=_(u"Bulk update"), target="many", + rights=['change_organization']) + QUICK_ACTIONS = [ + QA_EDIT + ] objects = UUIDModelManager() diff --git a/ishtar_common/urls.py b/ishtar_common/urls.py index 07e084e40..664a6b391 100644 --- a/ishtar_common/urls.py +++ b/ishtar_common/urls.py @@ -112,6 +112,15 @@ urlpatterns = [ check_rights(['change_organization', 'change_own_organization'])( views.OrganizationPersonEdit.as_view()), name='organization_person_edit'), + url(r'^organization-qa-bulk-update/(?P<pks>[0-9-]+)?/$', + check_rights(['change_organization', 'change_own_organization'])( + views.QAOrganizationForm.as_view()), + name='organization-qa-bulk-update'), + url(r'^organization-qa-bulk-update/(?P<pks>[0-9-]+)?/confirm/$', + check_rights(['change_organization', 'change_own_organization'])( + views.QAOrganizationForm.as_view()), + name='organization-qa-bulk-update-confirm', kwargs={"confirm": True}), + url(r'get-ishtaruser/(?P<type>.+)?$', views.get_ishtaruser, name='get-ishtaruser'), diff --git a/ishtar_common/views.py b/ishtar_common/views.py index 784a8bd0f..f1f7f2a82 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -2319,6 +2319,11 @@ class QABaseLockView(QAItemForm): return HttpResponseRedirect(reverse("success")) +class QAOrganizationForm(QAItemEditForm): + model = models.Organization + form_class = forms.QAOrganizationFormMulti + + class QAPersonForm(QAItemEditForm): model = models.Person form_class = forms.QAPersonFormMulti |