Beispiel #1
0
    def get(self):
        # Provide login/logout URLs.
        user_info = get_user_info()
        if user_info is None:
            login_url = users.create_login_url('/')
        else:
            login_url = users.create_logout_url('/')

        # Collect list of error messages which gets shown to the user.
        error_messages = self.request.params.getall('error_message')
        view_user = user_info  # for now
        did_search = False

        # Fetch media for view user.
        media = MediaObject.all().filter('owner', user_info)
        media = media.filter('lacks_document', True)
        media = media.order('creation')
        limit = 50
        if self.request.get("limit"):
            limit = long(self.request.get("limit"))
        media = media.fetch(limit)

        docs = Document.all().filter('owner', user_info)
        tags = self.request.get("tags")
        if tags:
            did_search = True
            for tag in re.split('\s*,\s*', tags):
                docs = docs.filter("tags", tag)
        docs = docs.fetch(limit)

        untagged_docs = Document.all().filter('owner', user_info).filter(
            "no_tags", True).fetch(limit)

        upcoming_due = Document.all().filter('owner', user_info)
        upcoming_due = upcoming_due.filter("due_date !=", None)
        upcoming_due = upcoming_due.order("due_date")
        upcoming_due = upcoming_due.fetch(30)

        top_message = ""
        if self.request.get("saved_doc"):
            docid = long(self.request.get("saved_doc"))
            top_message = "Saved <a href='/doc/%d'>doc %d</a>" % (docid, docid)

        # Render view.
        self.response.out.write(
            template.render('main.html', {
                "did_search": did_search,
                "media": media,
                "docs": docs,
                "untagged_docs": untagged_docs,
                "upcoming_due_docs": upcoming_due,
                "view_user": view_user,
                "login_url": login_url,
                "user_info": user_info,
                "top_message": top_message,
            },
                            debug=True))
Beispiel #2
0
  def get(self):
    # Provide login/logout URLs.
    user_info = get_user_info()
    if user_info is None:
      login_url = users.create_login_url('/')
    else:
      login_url = users.create_logout_url('/')

    # Collect list of error messages which gets shown to the user.
    error_messages = self.request.params.getall('error_message')
    view_user = user_info  # for now
    did_search = False

    # Fetch media for view user.
    media = MediaObject.all().filter('owner', user_info)
    media = media.filter('lacks_document', True)
    media = media.order('creation')
    limit = 50
    if self.request.get("limit"):
      limit = long(self.request.get("limit"))
    media = media.fetch(limit)

    docs = Document.all().filter('owner', user_info)
    tags = self.request.get("tags")
    if tags:
      did_search = True
      for tag in re.split('\s*,\s*', tags):
        docs = docs.filter("tags", tag)
    docs = docs.fetch(limit)

    untagged_docs = Document.all().filter('owner', user_info).filter("no_tags", True).fetch(limit)

    upcoming_due = Document.all().filter('owner', user_info)
    upcoming_due = upcoming_due.filter("due_date !=", None)
    upcoming_due = upcoming_due.order("due_date")
    upcoming_due = upcoming_due.fetch(30)

    top_message = ""
    if self.request.get("saved_doc"):
      docid = long(self.request.get("saved_doc"))
      top_message = "Saved <a href='/doc/%d'>doc %d</a>" % (docid, docid)

    # Render view.
    self.response.out.write(template.render('main.html', {
        "did_search": did_search,
        "media": media,
        "docs": docs,
        "untagged_docs": untagged_docs,
        "upcoming_due_docs": upcoming_due,
        "view_user": view_user,
        "login_url": login_url,
        "user_info": user_info,
        "top_message": top_message,
        }, debug=True))
Beispiel #3
0
  def get(self):
    if not users.is_current_user_admin():
      self.redirect('/?error_message=%s' % 'log-in required')

    used = set()
    for i in MediaObject.all():
      used.add(i.blob.key())

    for b in blobstore.BlobInfo.all():
      if b.key() not in used:
        b.delete()

    self.redirect('/')
Beispiel #4
0
  def get(self):
    if not users.is_current_user_admin():
      self.redirect('/?error_message=%s' % 'log-in required')

    used = set()
    for d in Document.all():
      used |= set(d.pages)

    dead = dict()
    for i in MediaObject.all():
      if i.key() not in used:
        dead[i.key()] = i

    for k in dead:
      dead[k].delete()

    self.redirect('/')
Beispiel #5
0
  def get(self):
    self.response.headers['Cache-Control'] = "private"
    self.response.headers['Content-Type'] = "text/plain; charset=utf-8"

    user = UserInfo.get_by_key_name('user:[email protected]')

    docs = Document.all().filter('owner', user)
    docs = docs.fetch(10000)
    self.response.out.write("# got %d docs\n" % len(docs))
    for doc in docs:
      self.response.out.write("%s tags[%s] date[%s] title[%s] \n" % (doc.display_url, doc.tag_comma_separated, doc.date_yyyy_mm_dd, doc.title_or_empty_string))
      for page in doc.pages:
        self.response.out.write(" has_page: %d\n" % (page.id_or_name()))
    meds = MediaObject.all().filter('owner', user)
    meds = meds.fetch(10000)
    self.response.out.write("# got %d mediaobjects\n" % len(meds))
    for mo in meds:
      self.response.out.write("%s creation[%s] size[%d]\n" % (mo.url_path, str(mo.creation), mo.size))
    def get(self):
        self.response.headers['Cache-Control'] = "private"
        self.response.headers['Content-Type'] = "text/plain; charset=utf-8"

        user = UserInfo.get_by_key_name('user:[email protected]')

        docs = Document.all().filter('owner', user)
        docs = docs.fetch(10000)
        self.response.out.write("# got %d docs\n" % len(docs))
        for doc in docs:
            self.response.out.write(
                "%s tags[%s] date[%s] title[%s] \n" %
                (doc.display_url, doc.tag_comma_separated, doc.date_yyyy_mm_dd,
                 doc.title_or_empty_string))
            for page in doc.pages:
                self.response.out.write(" has_page: %d\n" %
                                        (page.id_or_name()))
        meds = MediaObject.all().filter('owner', user)
        meds = meds.fetch(10000)
        self.response.out.write("# got %d mediaobjects\n" % len(meds))
        for mo in meds:
            self.response.out.write("%s creation[%s] size[%d]\n" %
                                    (mo.url_path, str(mo.creation), mo.size))