コード例 #1
0
ファイル: app.py プロジェクト: ToucheSir/svblog
def entries(name):
    """
    This page presents a user's blog posts and file uploads,
    allowing visitors to download the files individually.
    """

    if get_user(name) is not None:
        session['theme'] = get_user(name).theme
        entries = [e for e in Entry.query.all()]
        entries.reverse()
        uploads = [dict(userid=f.userid, filename=f.filename, filetype=f.filetype) \
                   for f in Upload.query.all()]

        if request.method == "POST":
            title, text = request.form['title'], request.form['text']
            text = urlify(text)

            entry_instance = Entry(name, title, text)
            edb.session.add(entry_instance)
            edb.session.commit()

            flash('Post successful!')
            return redirect(url_for('entries', name=name))
        else:
            return render_template('entries.html', username=name,
                                   uploads=uploads, entries=entries, theme=session['theme'])
    else:
        display("User does not exist.")
        return redirect(url_for('login'))
コード例 #2
0
ファイル: models.py プロジェクト: klanestro/libraro
    def save(self, force_insert=False, force_update=False):
        title = self.title()['eo']
        self.url = urlify(title)
        # "Mysterious Island, The"
        if title.startswith('La '):
            self.fileas = title[3:] + ", La"
        else:
            self.fileas = title

        # If it is just published
        if self.published == True and self.when_published == None:
            self.when_published = datetime.datetime.utcnow()

        super(Work, self).save(force_insert, force_update)

        workdir = self.workdir()
        if not os.path.exists(workdir):
            os.mkdir(workdir)

        if self.fulltext != "" and self.fulltext != None:
            xml = open(workdir+"/work.xml","w")
            xml.write(self.fulltext.encode('utf-8'))
            xml.close()
            self.fulltext = ""
            self.generate()
コード例 #3
0
ファイル: models.py プロジェクト: klanestro/libraro
 def save(self, force_insert=False, force_update=False):
     self.fileas = self.last + ', ' + self.first
     self.url = urlify(self.full())
     super(Person, self).save(force_insert, force_update)