summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-10-19 14:18:30 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-10-24 12:06:09 +0200
commit488d9c2a72142dbaed66cb11ae8a9629ea6fe923 (patch)
tree29f92a2c4caff32bb80907da9d659211f9291e1b
parentbef385bdb038c6f4f00ca8ba176c8f3d4ef5c5ed (diff)
downloadIshtar-488d9c2a72142dbaed66cb11ae8a9629ea6fe923.tar.bz2
Ishtar-488d9c2a72142dbaed66cb11ae8a9629ea6fe923.zip
Manage find basket modification wizard
-rw-r--r--archaeological_context_records/models.py2
-rw-r--r--archaeological_finds/forms.py11
-rw-r--r--archaeological_finds/ishtar_menu.py6
-rw-r--r--archaeological_finds/models_finds.py17
-rw-r--r--archaeological_finds/templates/ishtar/sheet_findbasket.html2
-rw-r--r--archaeological_finds/urls.py9
-rw-r--r--archaeological_finds/views.py22
-rw-r--r--archaeological_finds/wizards.py9
-rw-r--r--archaeological_operations/models.py3
-rw-r--r--[-rwxr-xr-x]example_project/media/upload/templates/document_reference.odtbin10678 -> 10626 bytes
10 files changed, 74 insertions, 7 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py
index ec79748c7..0aa5c961d 100644
--- a/archaeological_context_records/models.py
+++ b/archaeological_context_records/models.py
@@ -335,6 +335,7 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem,
]
history = HistoricalRecords()
+ objects = ExternalIdManager()
# fields
external_id = models.TextField(_(u"External ID"), blank=True, null=True)
@@ -411,7 +412,6 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem,
blank=True)
cached_label = models.TextField(_(u"Cached name"), null=True, blank=True,
db_index=True)
- objects = ExternalIdManager()
class Meta:
verbose_name = _(u"Context Record")
diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py
index 370f29cad..5ca8618d5 100644
--- a/archaeological_finds/forms.py
+++ b/archaeological_finds/forms.py
@@ -72,7 +72,7 @@ __all__ = [
'AdministrativeActTreatmentFileModifForm',
'DashboardTreatmentForm', 'DashboardTreatmentFileForm',
'RecordFormSelection', 'FindForm', 'DateForm', 'DatingFormSet',
- 'PreservationForm', 'FindBasketFormSelection',
+ 'PreservationForm', 'FindBasketFormSelection', 'FindBasketForm',
'FindSelect', 'FindFormSelection', 'FindFormSelectionWarehouseModule',
'MultipleFindFormSelection', 'MultipleFindFormSelectionWarehouseModule',
'FindMultipleFormSelection', 'check_form', 'check_exist', 'check_not_exist',
@@ -947,6 +947,15 @@ class FindBasketFormSelection(CustomFormSearch):
validators=[valid_id(models.FindBasket)])
+class FindBasketForm(IshtarForm):
+ form_label = _(u"Find basket")
+ label = forms.CharField(
+ label=_(u"Label"),
+ validators=[validators.MaxLengthValidator(1000)])
+ comment = forms.CharField(label=_(u"Comment"),
+ widget=forms.Textarea, required=False)
+
+
class NewFindBasketForm(forms.ModelForm):
class Meta:
model = models.FindBasket
diff --git a/archaeological_finds/ishtar_menu.py b/archaeological_finds/ishtar_menu.py
index 3dd98bdbd..afd624b74 100644
--- a/archaeological_finds/ishtar_menu.py
+++ b/archaeological_finds/ishtar_menu.py
@@ -66,6 +66,12 @@ MENU_SECTIONS = [
model=models.FindBasket,
access_controls=['view_find',
'view_own_find']),
+ MenuItem('find_basket_modification',
+ _(u"Modification"),
+ model=models.FindBasket,
+ access_controls=[
+ 'view_find',
+ 'view_own_find']),
MenuItem('find_basket_modification_add',
_(u"Manage items"),
model=models.FindBasket,
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py
index f6c8c6bf6..d97cfd6b0 100644
--- a/archaeological_finds/models_finds.py
+++ b/archaeological_finds/models_finds.py
@@ -579,6 +579,21 @@ class FindBasket(Basket, OwnPerms):
def get_query_owns(cls, ishtaruser):
return Q(user=ishtaruser)
+ def get_extra_actions(self, request):
+ """
+ For sheet template: return "Manage basket" action
+ """
+ # url, base_text, icon, extra_text, extra css class, is a quick action
+
+ # no particular rights: if you can view an itm you can add it to your
+ # own basket
+ actions = [
+ (reverse("select_itemsinbasket", args=[self.pk]),
+ _(u"Manage basket"),
+ "fa fa-shopping-basket", "", "", False),
+ ]
+ return actions
+
class FirstBaseFindView(object):
CREATE_SQL = """
@@ -898,7 +913,6 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms,
M2M_SEARCH_VECTORS = [
"datings__period__label", "object_types__label", "integrities__label",
"remarkabilities__label", "material_types__label"]
- objects = ExternalIdManager()
QA_EDIT = QuickAction(
url="find-qa-bulk-update", icon_class="fa fa-pencil",
@@ -938,6 +952,7 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms,
('warehouse', 'container__location__pk'),
('site', 'base_finds__context_record__archaeological_site__pk')
]
+ objects = ExternalIdManager()
# fields
base_finds = models.ManyToManyField(BaseFind, verbose_name=_(u"Base find"),
diff --git a/archaeological_finds/templates/ishtar/sheet_findbasket.html b/archaeological_finds/templates/ishtar/sheet_findbasket.html
index c9c442ccd..3c3ca1d3f 100644
--- a/archaeological_finds/templates/ishtar/sheet_findbasket.html
+++ b/archaeological_finds/templates/ishtar/sheet_findbasket.html
@@ -4,7 +4,7 @@
{% block head_title %}{% trans "Basket" %} - {{item.label}}{% endblock %}
{% block toolbar %}
-{% window_nav item window_id 'show-findbasket' 'select_itemsinbasket' %}
+{% window_nav item window_id 'show-findbasket' 'find_basket_modify' %}
{% endblock %}
{% block content %}
diff --git a/archaeological_finds/urls.py b/archaeological_finds/urls.py
index afc9bcba7..588c8d520 100644
--- a/archaeological_finds/urls.py
+++ b/archaeological_finds/urls.py
@@ -51,6 +51,12 @@ urlpatterns = [
url(r'^find_basket_creation/$',
check_rights(['view_find', 'view_own_find'])(
views.NewFindBasketView.as_view()), name='new_findbasket'),
+ url(r'^find_basket_modification/(?P<step>.+)?$',
+ check_rights(['view_find', 'view_own_find'])(
+ views.basket_modify_wizard),
+ name='find_basket_modification'),
+ url(r'find_basket_modify/(?P<pk>.+)/$',
+ views.find_basket_modify, name='find_basket_modify'),
url(r'^find_basket_modification_add/$',
check_rights(['view_find', 'view_own_find'])(
views.SelectBasketForManagement.as_view()),
@@ -206,7 +212,8 @@ urlpatterns = [
url(r'get-find-shortcut/(?P<type>.+)?$',
views.get_find, name='get-find-shortcut',
kwargs={'full': 'shortcut'}),
- url(r'^show-find/basket-(?P<pk>.+)/(?P<type>.+)?$', views.show_findbasket,
+ url(r'^show-find/basket-(?:(?P<pk>.+)/(?P<type>.+)?)?$',
+ views.show_findbasket,
name='show-findbasket'),
url(r'^display-find/basket-(?P<pk>.+)/$', views.display_findbasket,
name='display-findbasket'),
diff --git a/archaeological_finds/views.py b/archaeological_finds/views.py
index 7523df145..c340639c5 100644
--- a/archaeological_finds/views.py
+++ b/archaeological_finds/views.py
@@ -118,11 +118,31 @@ get_find_basket = get_item(
)
basket_search_wizard = FindBasketSearch.as_view(
- [('general-basket_search', FindBasketFormSelection)],
+ [('selec-find_basket_search', FindBasketFormSelection)],
label=_(u"Basket search"),
url_name='find_basket_search',
)
+basket_modify_wizard = FindBasketEditWizard.as_view(
+ [
+ ('selec-find_basket_modification', FindBasketFormSelection),
+ ('basket-find_basket_modification', FindBasketForm),
+ ('final-find_basket_modification', FinalForm)
+ ],
+ label=_(u"Basket modify"),
+ url_name='find_basket_modification',
+)
+
+
+def find_basket_modify(request, pk):
+ basket_modify_wizard(request)
+ key = 'selec-find_basket_modification'
+ FindBasketEditWizard.session_set_value(
+ request, key, 'pk', pk, reset=True)
+ return redirect(
+ reverse('find_basket_modification',
+ kwargs={'step': 'basket-find_basket_modification'}))
+
def check_preservation_module(self):
return get_current_profile().preservation
diff --git a/archaeological_finds/wizards.py b/archaeological_finds/wizards.py
index ef51d85d1..0e0fe80e1 100644
--- a/archaeological_finds/wizards.py
+++ b/archaeological_finds/wizards.py
@@ -234,3 +234,12 @@ class TreatmentFileEditAdministrativeActWizard(
class FindBasketSearch(SearchWizard):
model = models.FindBasket
+
+
+class FindBasketWizard(Wizard):
+ model = models.FindBasket
+ wizard_done_window = reverse_lazy('show-findbasket')
+
+
+class FindBasketEditWizard(FindBasketWizard):
+ edit = True
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index 1d7f17fa8..56af40ba0 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -198,7 +198,6 @@ class ArchaeologicalSite(BaseHistorizedItem, OwnPerms, ValueGetter,
activate(language_code)
EXTRA_REQUEST_KEYS[unicode(v[0])] = v[1]
deactivate()
- objects = SiteManager()
UP_MODEL_QUERY = {
"operation": (pgettext_lazy("key for text search", u"operation"),
@@ -208,6 +207,8 @@ class ArchaeologicalSite(BaseHistorizedItem, OwnPerms, ValueGetter,
('operation', 'operations__pk'),
]
+ # objects = SiteManager()
+
reference = models.CharField(_(u"Reference"), max_length=200, unique=True)
name = models.CharField(_(u"Name"), max_length=200,
null=True, blank=True)
diff --git a/example_project/media/upload/templates/document_reference.odt b/example_project/media/upload/templates/document_reference.odt
index acda588fb..ffd697841 100755..100644
--- a/example_project/media/upload/templates/document_reference.odt
+++ b/example_project/media/upload/templates/document_reference.odt
Binary files differ