Пример #1
0
 def get(self, docid):
     user_info = get_user_info()
     if user_info is None:
         self.redirect("/?error_message=%s" % "login required to view docs")
     docid = long(docid)
     doc = Document.get_by_id(docid, parent=user_info)
     if doc is None:
         self.response.out.write("Docid %d not found." % (docid))
         return
     pages = MediaObject.get(doc.pages)
     size = self.request.get("size")
     if not size:
         size = 1200
     show_single_list = long(size) > 600
     self.response.out.write(
         template.render(
             "doc.html",
             {
                 "doc": doc,
                 "pages": pages,
                 "user_info": user_info,
                 "size": size,
                 "show_single_list": show_single_list,
             },
             debug=True,
         )
     )
Пример #2
0
    def post(self):
        user_info = get_user_info()
        if user_info is None:
            self.redirect('/?error_message=%s' % 'login required to view docs')
        docid = long(self.request.get("docid"))
        doc = Document.get_by_id(docid, parent=user_info)
        if doc is None:
            self.response.out.write("Docid %d not found." % (docid))
            return

        mode = self.request.get("mode")
        if mode == "break":
            break_and_delete_doc(user_info, doc)
            self.response.out.write(
                "[&lt;&lt; <a href='/'>Back</a>] Docid %d deleted and images broken out as un-annotated."
                % docid)
            return
        if mode == "delete":
            delete_doc_and_images(user_info, doc)
            self.response.out.write(
                "[&lt;&lt; <a href='/'>Back</a>] Docid %d and its images deleted."
                % docid)
            return

        # Simple properties:
        doc.physical_location = self.request.get("physical_location")
        doc.title = self.request.get("title")

        # Tags
        doc.tags = [
            x for x in re.split('\s*,\s*', self.request.get("tags")) if x
        ]
        doc.no_tags = (len(doc.tags) == 0)

        # Document Date
        date = self.request.get("date")
        if date:
            doc.doc_date = datetime.datetime.strptime(date, "%Y-%m-%d")
            doc.no_date = False
        else:
            doc.doc_date = None
            doc.no_date = True

        # Due date
        due_date_str = self.request.get("due_date")
        doc.due_date = None
        if due_date_str:
            doc.due_date = datetime.datetime.strptime(due_date_str, "%Y-%m-%d")

        def store():
            db.put(doc)

        db.run_in_transaction(store)
        self.redirect("/?saved_doc=" + str(docid))
Пример #3
0
    def post(self):
        user_info = get_user_info()
        if user_info is None:
            self.redirect("/?error_message=%s" % "login required to view docs")
        docid = long(self.request.get("docid"))
        doc = Document.get_by_id(docid, parent=user_info)
        if doc is None:
            self.response.out.write("Docid %d not found." % (docid))
            return

        mode = self.request.get("mode")
        if mode == "break":
            break_and_delete_doc(user_info, doc)
            self.response.out.write(
                "[&lt;&lt; <a href='/'>Back</a>] Docid %d deleted and images broken out as un-annotated." % docid
            )
            return
        if mode == "delete":
            delete_doc_and_images(user_info, doc)
            self.response.out.write("[&lt;&lt; <a href='/'>Back</a>] Docid %d and its images deleted." % docid)
            return

        # Simple properties:
        doc.physical_location = self.request.get("physical_location")
        doc.title = self.request.get("title")

        # Tags
        doc.tags = [x for x in re.split("\s*,\s*", self.request.get("tags")) if x]
        doc.no_tags = len(doc.tags) == 0

        # Document Date
        date = self.request.get("date")
        if date:
            doc.doc_date = datetime.datetime.strptime(date, "%Y-%m-%d")
            doc.no_date = False
        else:
            doc.doc_date = None
            doc.no_date = True

        # Due date
        due_date_str = self.request.get("due_date")
        doc.due_date = None
        if due_date_str:
            doc.due_date = datetime.datetime.strptime(due_date_str, "%Y-%m-%d")

        def store():
            db.put(doc)

        db.run_in_transaction(store)
        self.redirect("/?saved_doc=" + str(docid))
Пример #4
0
 def get(self, docid):
   user_info = get_user_info()
   if user_info is None:
     self.redirect('/?error_message=%s' % 'login required to view docs')
   docid = long(docid)
   doc = Document.get_by_id(docid, parent=user_info)
   if doc is None:
     self.response.out.write("Docid %d not found." % (docid))
     return
   pages = MediaObject.get(doc.pages)
   size = self.request.get("size")
   if not size:
     size = 1200
   show_single_list = long(size) > 600
   self.response.out.write(template.render('doc.html',
                                           {"doc": doc,
                                            "pages": pages,
                                            "user_info": user_info,
                                            "size": size,
                                            "show_single_list": show_single_list},
                                           debug=True))