summaryrefslogtreecommitdiff
path: root/archaeological_finds
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_finds')
-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
7 files changed, 71 insertions, 5 deletions
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