Beispiel #1
0
 def update(self, id):
     """ update user info """
     doc = cls.find_or_404(id)
     form = ExtendedControlPanelForm(obj=doc)
     if form.validate_on_submit():
         doc._from_form(form)
         doc.save()
         return model.redirect(doc.url_for())
     else:
         url = doc.url_for("update")
         return model.render_template(name + "/update.html", doc=doc, form=form, url=url)
Beispiel #2
0
 def get_info(self, id):
     doc = cls.find_or_404(id)
     redo = model.request.args.get("redo", "")
     if "google_volumes" not in doc or not doc["google_volumes"] or redo:
         query = "intitle:%s" % doc["title"]
         for a in doc["authors"]:
             if a and a != "unknown" and a != "?":
                 query += "+inauthor:%s" % a
         params = {"q": query}
         r = requests.get(google_url, params=params)
         j = simplejson.loads(r.text)
         doc["google_volumes"] = []
         if j["totalItems"]:
             for v in j["items"]:
                 doc.google_volumes.append(v["volumeInfo"])
         doc.save()
     return model.render_template(name + "/get_info.html", doc=doc)
Beispiel #3
0
 def bookstore_list(self):
     """ displays list of books to look for in a bookstore """
     q = {"want_to_own": True, "owned": False}
     cursor = getattr(connection, name).find(q)
     doclist = list(cursor.sort(u"author_string", 1))
     return model.render_template(name + "/mini-index.html", title="Bookstore List", doclist=doclist)
Beispiel #4
0
 def index(self):
     doclist = list(getattr(connection, name).find())
     form = cls.getMultiForm(index_form_fields, doclist)
     form.subforms = [form._fields[str(x._id)] for x in doclist]
     url = url_for("%s:%s" % (cls.viewName(), "index_form_post"))
     return model.render_template(name + "/index.html", doclist=doclist, form=form, url=url)
Beispiel #5
0
 def get(self, id):
     doc = cls.find_or_404(id)
     control_panel = ControlPanelForm(obj=doc)
     return model.render_template(name + "/get.html", doc=doc, form=control_panel)