Author
|
zPlus <zplus@peers.community>
2020-06-05 05:36:43
|
Committer
|
Gogs <gogitservice@gmail.com>
2020-06-05 05:36:43
|
Commit
|
aa365c2
(patch)
|
Tree
|
3c05111
|
Parent(s)
|
|
Merge branch 'master' of necklace/freepost into master
commits diff:
7ee2c69..aa365c2
2 files changed,
22 insertions,
0 deletions
—
download
Diffstat
Diff options
+3/-0
M freepost/__init__.py
661
|
661
|
|
# If there is a URL, make sure it has a "scheme"
|
662
|
662
|
|
if len (link) > 0 and urlparse (link).scheme == '':
|
663
|
663
|
|
link = 'http://' + link
|
|
664
|
+ |
|
|
665
|
+ |
if database.post_exists(link):
|
|
666
|
+ |
return template ('submit.html', flash='Link has already been submitted.')
|
664
|
667
|
|
|
665
|
668
|
|
# Retrieve topics
|
666
|
669
|
|
topics = request.forms.getunicode ('topics')
|
+19/-0
M freepost/database.py
97
|
97
|
|
|
98
|
98
|
|
return cursor.fetchone() is not None
|
99
|
99
|
|
|
|
100
|
+ |
# Check if post with same link exists
|
|
101
|
+ |
def post_exists (link):
|
|
102
|
+ |
if not link:
|
|
103
|
+ |
return None
|
|
104
|
+ |
|
|
105
|
+ |
with db:
|
|
106
|
+ |
cursor = db.execute(
|
|
107
|
+ |
"""
|
|
108
|
+ |
SELECT *
|
|
109
|
+ |
FROM post
|
|
110
|
+ |
WHERE LOWER(link) = LOWER(:link)
|
|
111
|
+ |
""",
|
|
112
|
+ |
{
|
|
113
|
+ |
'link': link
|
|
114
|
+ |
}
|
|
115
|
+ |
)
|
|
116
|
+ |
|
|
117
|
+ |
return cursor.fetchone() is not None
|
|
118
|
+ |
|
100
|
119
|
|
# Create new user account
|
101
|
120
|
|
def new_user (username, password):
|
102
|
121
|
|
# Create a hash_id for the new post
|