Example #1
0
    def POST(self):
        if not session().logged:
            raise web.seeother('/register')

        i = web.input(authors="",
                      url=None,
                      title=None,
                      comments=[],
                      year=None,
                      enabled=True,
                      subtitle='',
                      time=datetime.utcnow(),
                      votes=1,
                      cite={
                          'mla': '',
                          'apa': '',
                          'chicago': ''
                      })
        db = Db('db/openjournal')

        def next_pid():
            papers = db.get('papers')
            return papers[-1]['pid'] + 1 if papers else 0

        i.submitter = session()['uname']
        if i.authors:
            i.authors = map(self.parse_author, i.authors.split(','))
        i.pid = next_pid()
        record_submission(i.submitter, i.pid)
        record_vote(i.submitter, i.submitter, i.pid)
        db.append('papers', dict(i))
        Search().index()
        raise web.seeother('/')