diff options
| -rw-r--r-- | archaeological_finds/models.py | 7 | ||||
| -rw-r--r-- | archaeological_finds/templates/ishtar/sheet_findbasket.html | 16 | ||||
| -rw-r--r-- | archaeological_finds/templates/ishtar/sheet_findbasket_pdf.html | 18 | ||||
| -rw-r--r-- | archaeological_finds/templates/ishtar/sheet_findbasket_window.html | 3 | ||||
| -rw-r--r-- | archaeological_finds/urls.py | 5 | ||||
| -rw-r--r-- | archaeological_finds/views.py | 3 | ||||
| -rw-r--r-- | ishtar_common/context_processors.py | 7 | ||||
| -rw-r--r-- | ishtar_common/models.py | 10 | ||||
| -rw-r--r-- | ishtar_common/static/media/style.css | 6 | ||||
| -rw-r--r-- | ishtar_common/templates/base.html | 2 | ||||
| -rw-r--r-- | ishtar_common/templates/ishtar/blocks/window_tables/dynamic_documents.html | 1 | ||||
| -rw-r--r-- | ishtar_common/templatetags/window_tables.py | 15 | ||||
| -rw-r--r-- | ishtar_common/views.py | 7 | 
13 files changed, 90 insertions, 10 deletions
| diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py index af3009351..43c18828c 100644 --- a/archaeological_finds/models.py +++ b/archaeological_finds/models.py @@ -384,6 +384,10 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):              lbl += u' ({})'.format(base)          return lbl +    @classmethod +    def get_owns(cls, user): +        return FindBasket.objects.filter(user=user) +      def get_first_base_find(self):          q = self.base_finds          if not q.count(): @@ -541,7 +545,8 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):  class FindBasket(Basket): -    items = models.ManyToManyField(Find, blank=True, null=True) +    items = models.ManyToManyField(Find, blank=True, null=True, +                                   related_name='basket')  class FindSource(Source): diff --git a/archaeological_finds/templates/ishtar/sheet_findbasket.html b/archaeological_finds/templates/ishtar/sheet_findbasket.html new file mode 100644 index 000000000..00b52ab7b --- /dev/null +++ b/archaeological_finds/templates/ishtar/sheet_findbasket.html @@ -0,0 +1,16 @@ +{% extends "ishtar/sheet.html" %} +{% load i18n window_tables from_dict %} + +{% block head_sheet %} +{{block.super}} +<h1>{% trans "Find"%}</h1> +{% endblock %} + +{% block content %} + +<div class='tool'>{%trans "Export as:"%} <a href='{% url show-findbasket item.pk "odt" %}'>{%trans "OpenOffice.org file"%}</a>, <a href='{% url show-findbasket item.pk "pdf" %}'>{%trans "PDF file"%}</a></div> +<div class='tool modify'><a href='{% url select_itemsinbasket item.pk %}'>{% trans "Modify" %}</a></div> + +{% dynamic_table_document_large finds 'finds_for_ope' 'basket' item.pk 'TABLE_COLS_FOR_OPE' output %} + +{% endblock %} diff --git a/archaeological_finds/templates/ishtar/sheet_findbasket_pdf.html b/archaeological_finds/templates/ishtar/sheet_findbasket_pdf.html new file mode 100644 index 000000000..37eecf81b --- /dev/null +++ b/archaeological_finds/templates/ishtar/sheet_findbasket_pdf.html @@ -0,0 +1,18 @@ +{% extends "ishtar/sheet_findbasket.html" %} +{% block header %} +<link rel="stylesheet" href="{{STATIC_URL}}/media/style_basic.css" /> +{% endblock %} +{% block main_head %} +{{ block.super }} +<div id="pdfheader"> +Ishtar – {{APP_NAME}} – {{item}} +</div> +{% endblock %} +{%block head_sheet%}{%endblock%} +{%block main_foot%} +<div id="pdffooter"> +– <pdf:pagenumber/> – +</div> +</body> +</html> +{%endblock%} diff --git a/archaeological_finds/templates/ishtar/sheet_findbasket_window.html b/archaeological_finds/templates/ishtar/sheet_findbasket_window.html new file mode 100644 index 000000000..5bc46d5c7 --- /dev/null +++ b/archaeological_finds/templates/ishtar/sheet_findbasket_window.html @@ -0,0 +1,3 @@ +{% extends "ishtar/sheet_findbasket.html" %} +{% block main_head %}{%endblock%} +{% block main_foot %}{%endblock%} diff --git a/archaeological_finds/urls.py b/archaeological_finds/urls.py index deaaaff18..27a2bdc76 100644 --- a/archaeological_finds/urls.py +++ b/archaeological_finds/urls.py @@ -58,9 +58,6 @@ urlpatterns = patterns(      url(r'^find_basket_creation/$',          check_rights(['change_find', 'change_own_find'])(              views.NewFindBasketView.as_view()), name='new_findbasket'), -    url(r'^find_basket_creation/$', -        check_rights(['change_find', 'change_own_find'])( -            views.NewFindBasketView.as_view()), name='new_findbasket'),      url(r'^find_basket_modification_add/$',          check_rights(['change_find', 'change_own_find'])(              views.SelectBasketForManagement.as_view()), @@ -113,6 +110,8 @@ urlpatterns += patterns(          'get_findsource', name='get-findsource'),      url(r'show-findsource(?:/(?P<pk>.+))?/(?P<type>.+)?$', 'show_findsource',          name=models.FindSource.SHOW_URL), +    url(r'show-find/basket-(?P<pk>.+)/(?P<type>.+)?$', 'show_findbasket', +        name='show-findbasket'),      url(r'show-find(?:/(?P<pk>.+))?/(?P<type>.+)?$', 'show_find',          name=models.Find.SHOW_URL),      url(r'show-historized-find/(?P<pk>.+)?/(?P<date>.+)?$', diff --git a/archaeological_finds/views.py b/archaeological_finds/views.py index 871a5b90d..77d3522ca 100644 --- a/archaeological_finds/views.py +++ b/archaeological_finds/views.py @@ -62,6 +62,7 @@ find_extra_keys = {      'base_finds__find__description':          'base_finds__find__description__icontains',      'base_finds__batch': 'base_finds__batch', +    'basket': 'basket',      'image': 'image__isnull'}  get_find = get_item( @@ -95,6 +96,8 @@ get_findsource = get_item(  show_find = show_item(models.Find, 'find')  revert_find = revert_item(models.Find) +show_findbasket = show_item(models.FindBasket, 'findbasket') +  find_creation_wizard = FindWizard.as_view([      ('selecrecord-find_creation', RecordFormSelection),      ('find-find_creation', FindForm), 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]: | 
