diff options
Diffstat (limited to 'ishtar_common/views.py')
| -rw-r--r-- | ishtar_common/views.py | 41 | 
1 files changed, 26 insertions, 15 deletions
| diff --git a/ishtar_common/views.py b/ishtar_common/views.py index 554fcc839..2278cf47a 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -374,21 +374,23 @@ def show_item(model, name):          date = 'date' in dct and dct.pop('date')          dct['window_id'] = "%s-%d-%s" % (name, item.pk,                                        datetime.datetime.now().strftime('%M%s')) -        if date: -            try: -                date = datetime.datetime.strptime(date, '%Y-%m-%dT%H:%M:%S.%f') -                item = item.get_previous(date=date) -                assert item != None -            except (ValueError, AssertionError): -                return HttpResponse(None, mimetype='text/plain') -            dct['previous'] = item._previous -            dct['next'] = item._next -        else: -            historized = item.history.all() -            if historized: -                item.history_date = historized[0].history_date -            if len(historized) > 1: -                dct['previous'] = historized[1].history_date +        if hasattr(item, 'history'): +            if date: +                try: +                    date = datetime.datetime.strptime(date, +                                                      '%Y-%m-%dT%H:%M:%S.%f') +                    item = item.get_previous(date=date) +                    assert item != None +                except (ValueError, AssertionError): +                    return HttpResponse(None, mimetype='text/plain') +                dct['previous'] = item._previous +                dct['next'] = item._next +            else: +                historized = item.history.all() +                if historized: +                    item.history_date = historized[0].history_date +                if len(historized) > 1: +                    dct['previous'] = historized[1].history_date          dct['item'], dct['item_name'] = item, name          context_instance = RequestContext(request)          context_instance.update(dct) @@ -545,6 +547,15 @@ def new_item(model, frm):  new_person = new_item(models.Person, PersonForm)  new_organization = new_item(models.Organization, OrganizationForm)  new_author = new_item(models.Author, AuthorForm) +show_person = show_item(models.Person, 'person') +get_person = get_item(models.Person, +        'get_person', 'person', +      extra_request_keys={ +                  'name':'name__icontains', +                  'surname':'surname__icontains', +                  'attached_to':'attached_to__pk', +                  'person_types':'person_types__pk__in', +                  },)  def action(request, action_slug, obj_id=None, *args, **kwargs):      """ | 
