summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2016-05-22 22:22:32 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2016-05-22 22:22:32 +0200
commite45b6042dd31f046226e29ad07e1638c7ff3b437 (patch)
treea4d6b2acc1167a30f51966f3da9df21eca1dfebc /ishtar_common
parenta35bb6b362f99f7b2c3d38dc8bbc54f234ac4dd7 (diff)
downloadIshtar-e45b6042dd31f046226e29ad07e1638c7ff3b437.tar.bz2
Ishtar-e45b6042dd31f046226e29ad07e1638c7ff3b437.zip
Find: sheet for basket - manage default basket selection
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/context_processors.py7
-rw-r--r--ishtar_common/models.py10
-rw-r--r--ishtar_common/static/media/style.css6
-rw-r--r--ishtar_common/templates/base.html2
-rw-r--r--ishtar_common/templates/ishtar/blocks/window_tables/dynamic_documents.html1
-rw-r--r--ishtar_common/templatetags/window_tables.py15
-rw-r--r--ishtar_common/views.py7
7 files changed, 42 insertions, 6 deletions
diff --git a/ishtar_common/context_processors.py b/ishtar_common/context_processors.py
index 03ba9bc36..76f58bf8e 100644
--- a/ishtar_common/context_processors.py
+++ b/ishtar_common/context_processors.py
@@ -77,10 +77,13 @@ def get_base_context(request):
current = model_name in request.session and request.session[model_name]
items = []
for item in model.get_owns(request.user):
- selected = unicode(item.pk) == current
+ pk = unicode(item.pk)
+ if item.IS_BASKET:
+ pk = "basket-" + pk
+ selected = pk == current
if selected:
cls = item.get_short_menu_class()
- items.append((item.pk, shortify(unicode(item), 60),
+ items.append((pk, shortify(unicode(item), 60),
selected, item.get_short_menu_class()))
if items:
dct['current_menu'].append((lbl, model_name, cls, items))
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 3162a4843..33ae05369 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -480,6 +480,7 @@ class Basket(models.Model):
Abstract class for a basket
Subclass must be defined with an "items" ManyToManyField
"""
+ IS_BASKET = True
label = models.CharField(_(u"Label"), max_length=1000)
comment = models.TextField(_(u"Comment"), blank=True, null=True)
user = models.ForeignKey('IshtarUser', blank=True, null=True)
@@ -492,6 +493,14 @@ class Basket(models.Model):
def __unicode__(self):
return self.label
+ def get_short_menu_class(self):
+ return 'basket'
+
+ @property
+ def associated_filename(self):
+ return "{}-{}".format(datetime.date.today().strftime(
+ "%Y-%m-%d"), slugify(self.label))
+
class ItemKey(models.Model):
key = models.CharField(_(u"Key"), max_length=100)
@@ -569,6 +578,7 @@ class HistoryError(Exception):
class BaseHistorizedItem(Imported):
+ IS_BASKET = False
history_modifier = models.ForeignKey(
User, related_name='+', on_delete=models.SET_NULL,
verbose_name=_(u"Last editor"), blank=True, null=True)
diff --git a/ishtar_common/static/media/style.css b/ishtar_common/static/media/style.css
index 1590c1738..1d47bcbd9 100644
--- a/ishtar_common/static/media/style.css
+++ b/ishtar_common/static/media/style.css
@@ -45,6 +45,12 @@ a.add-button,
color:#000;
}
+#context_menu .basket{
+ color:#000;
+ font-weight: bold;
+ font-style: italic;
+}
+
/* borders */
a.add-button, a.remove,
#progress-content,
diff --git a/ishtar_common/templates/base.html b/ishtar_common/templates/base.html
index 4f84e3e62..1bab3d647 100644
--- a/ishtar_common/templates/base.html
+++ b/ishtar_common/templates/base.html
@@ -74,7 +74,7 @@
<td>
<select class='{{main_cls}}' id='current_{{model_name}}'>
<option class='normal' value=''>--</option>
- {% for val, label, selected, cls in items %}<option class='{{cls}}' value='{{val}}'{%if selected%} selected="selected"{%endif%}>{{label}}</option>
+ {% for val, label, selected, cls in items %}<option class='{{cls}}' value='{{val}}'{% if selected %} selected="selected"{%endif%}>{{label}}</option>
{% endfor %}</select>
</td>{% with 'show-'|add:model_name as model_url%}
<td><a href='#' onclick='load_current_window("{% url model_url 0 %}", "{{model_name}}");' class='display_details'>{% trans "Details" %}</a></td>
diff --git a/ishtar_common/templates/ishtar/blocks/window_tables/dynamic_documents.html b/ishtar_common/templates/ishtar/blocks/window_tables/dynamic_documents.html
index 7239b64fc..8850bd34a 100644
--- a/ishtar_common/templates/ishtar/blocks/window_tables/dynamic_documents.html
+++ b/ishtar_common/templates/ishtar/blocks/window_tables/dynamic_documents.html
@@ -42,6 +42,7 @@ setTimeout(
alert("{% trans "An error as occured during search. Check your query fields." %}");
}
});
+ {% if large %}jQuery("#grid_{{name}}").jqGrid('setGridHeight', 400);{% endif %}
}, 200);
</script>
diff --git a/ishtar_common/templatetags/window_tables.py b/ishtar_common/templatetags/window_tables.py
index cdd681b52..8be4e5559 100644
--- a/ishtar_common/templatetags/window_tables.py
+++ b/ishtar_common/templatetags/window_tables.py
@@ -44,8 +44,9 @@ ASSOCIATED_MODELS['finds_docs'] = (FindSource, 'get-findsource', '')
@register.simple_tag(takes_context=True)
-def dynamic_table_document(context, caption, associated_model, key, value,
- table_cols='TABLE_COLS', output='html'):
+def dynamic_table_document(
+ context, caption, associated_model, key, value,
+ table_cols='TABLE_COLS', output='html', large=False):
if not table_cols:
table_cols = 'TABLE_COLS'
model, url, url_full = ASSOCIATED_MODELS[associated_model]
@@ -68,6 +69,7 @@ def dynamic_table_document(context, caption, associated_model, key, value,
'no_result': unicode(_("No results")),
'loading': unicode(_("Loading...")),
'encoding': settings.ENCODING or 'utf-8',
+ 'large': large
})
return t.render(context)
else:
@@ -103,3 +105,12 @@ def dynamic_table_document(context, caption, associated_model, key, value,
'data': data
})
return t.render(context)
+
+
+@register.simple_tag(takes_context=True)
+def dynamic_table_document_large(
+ context, caption, associated_model, key,
+ value, table_cols='TABLE_COLS', output='html'):
+ return dynamic_table_document(
+ context, caption, associated_model, key,
+ value, table_cols, output, large=True)
diff --git a/ishtar_common/views.py b/ishtar_common/views.py
index 752cbcc74..59cfe6321 100644
--- a/ishtar_common/views.py
+++ b/ishtar_common/views.py
@@ -417,7 +417,12 @@ def get_item(model, func_name, default_name, extra_request_keys=[],
if 'submited' not in request_items:
if default_name in request.session and \
request.session[default_name]:
- dct = {"pk": request.session[default_name]}
+ value = request.session[default_name]
+ if 'basket-' in value:
+ dct = {"basket__pk":
+ request.session[default_name].split('-')[-1]}
+ else:
+ dct = {"pk": request.session[default_name]}
elif not dct:
for name in relative_session_names.keys():
if name in request.session and request.session[name]: