Beispiel #1
0
    def merge(self):
        person_ids = h.checkboxes(request, 'person_id_')

        c.persons = meta.Session\
                       .query(model.Person)\
                       .filter(model.Person.id.in_(person_ids))\
                       .all()
        c.person_ids_str = ",".join(person_ids)
        return render('person/merge.mako')
Beispiel #2
0
    def delete_many(self):
        for item in h.checkboxes(request, 'item_id_'):
            db_item = meta.find(model.Medium, item)
            meta.Session.delete(db_item)
            h.flash(_("deleted: %s") % db_item.title)

        meta.Session.commit()

        return redirect(url(controller='medium', action='index'))
Beispiel #3
0
    def checkout_post(self):
        borrower_id = int(request.params.get('borrower'))

        if not borrower_id or int(borrower_id) < 0:
            log.debug("redirect because no borrower_id")

            ids = ','.join(h.checkboxes(request, 'item_id_'))
            log.debug("ids: %s" % ids)
            return redirect(url(controller='borrow', action='add_borrower', media_ids=ids))
        else:
            borrower = meta.Session.query(model.Borrower).get(borrower_id)
            if not borrower:
                raise Exception("could not find borrower '%d'" % borrower_id)

        log.debug("borrower_id: %s" % borrower_id)
        for item in h.checkboxes(request, 'item_id_'):
            log.debug("checkout: %s" % item)
            self.__checkout_post__(item, borrower)

        meta.Session.commit()
        return redirect(url(controller='borrow', action='edit_borrower', id=borrower_id))
Beispiel #4
0
    def map_to_medium_post(self):
        media_id = request.params.get("media_id", None)

        if request.params.get("next_page", None):
            page = int(request.params.get("page", 1))
            log.debug("page: %s" % page)

            selected_asins = ",".join(h.checkboxes(request, "item_id_"))
            log.debug("selected_asins: %s" % selected_asins)

            query = request.params.get("query")
            log.debug("query: %s" % query)

            return redirect(
                url(
                    controller="amazon",
                    action="map_to_medium",
                    id=media_id,
                    page=page + 1,
                    selected_asins=selected_asins,
                    query=query,
                )
            )

        medium = meta.Session.query(model.Medium).get(media_id)
        asins = []
        for item in h.checkboxes(request, "item_id_"):
            record = model.MediaToAsin()
            record.asin = item
            asins.append(item)
            medium.asins.append(record)

        h.flash(_("attached %s amazon ids to media id %s: %s") % (len(asins), media_id, ", ".join(asins)))

        meta.Session.commit()
        self.__query_actors__(media_id)
        if not medium.image_data:
            return redirect(url(controller="amazon", action="query_images", id=media_id, page=None))
        else:
            return redirect(url(controller="medium", action="edit", id=media_id, page=None))
Beispiel #5
0
    def checkin_post(self):
        #~ id = request.params.get('id')
        #~ borrower = meta.find(model.Borrower, id)
        for item in h.checkboxes(request, 'item_id_'):
            record = meta.Session.query(model.BorrowAct).get(item)
            if not record:
                raise Exception("could not find BorrowAct '%s'" % item)

            record.returned_ts = datetime.now()
            meta.Session.add(record)
            borrower_link = h.tmpl('borrow/snippets.mako', 'link_to_borrower')\
                             .render_unicode(item=record.borrower, h=h)
            medium_link = h.tmpl('medium/snippets.mako', 'link_to_medium')\
                           .render_unicode(item=record.medium, h=h)
            h.flash(_("%s has returned medium '%s'") % (borrower_link, medium_link),
                    escape=False)

        meta.Session.commit()
        return redirect(url(controller='borrow', action='index'))