aboutsummaryrefslogtreecommitdiff
path: root/pastebin.py
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2022-02-11 19:30:19 -0500
committerB. Stack <bgstack15@gmail.com>2022-02-11 19:30:19 -0500
commit4cd7dfecfbe0d9d5cc5db944e47da8c058e55166 (patch)
treef7145e18cf45646b750c025bcfb591612cb40aa0 /pastebin.py
parentupdate style to mine (diff)
downloadstackbin-4cd7dfecfbe0d9d5cc5db944e47da8c058e55166.tar.gz
stackbin-4cd7dfecfbe0d9d5cc5db944e47da8c058e55166.tar.bz2
stackbin-4cd7dfecfbe0d9d5cc5db944e47da8c058e55166.zip
add support for title, and ensure no js
Diffstat (limited to 'pastebin.py')
-rw-r--r--pastebin.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/pastebin.py b/pastebin.py
index ec79909..4d5c231 100644
--- a/pastebin.py
+++ b/pastebin.py
@@ -22,15 +22,17 @@ def check_user_status():
class Paste(db.Model):
id = db.Column(db.Integer, primary_key=True)
code = db.Column(db.Text)
+ title = db.Column(db.Text)
pub_date = db.Column(db.DateTime)
user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
is_private = db.Column(db.Boolean)
parent_id = db.Column(db.Integer, db.ForeignKey('paste.id'))
parent = db.relationship('Paste', lazy=True, backref='children', uselist=False, remote_side=[id])
- def __init__(self, user, code, parent=None, is_private=False):
+ def __init__(self, user, code, title, parent=None, is_private=False):
self.user = user
self.code = code
+ self.title = title
self.is_private = is_private
self.pub_date = datetime.utcnow()
self.parent = parent
@@ -49,7 +51,10 @@ def new_paste():
parent = Paste.query.get(reply_to)
if request.method == 'POST' and request.form['code']:
is_private = bool(request.form.get('is_private'))
- paste = Paste(g.user, request.form['code'], parent=parent, is_private=is_private)
+ title = "Untitled paste"
+ if request.form['pastetitle'] and request.form['pastetitle'] != "Enter title here":
+ title = request.form['pastetitle']
+ paste = Paste(g.user, request.form['code'], title, parent=parent, is_private=is_private)
db.session.add(paste)
db.session.commit()
sign = Signer(app.secret_key, salt='jackson').sign(str(paste.id)) \
bgstack15