Author
|
zPlus <zplus@peers.community>
2018-07-19 06:45:09
|
Committer
|
zPlus <zplus@peers.community>
2018-07-19 06:45:09
|
Commit
|
79b4349
(patch)
|
Tree
|
408741d
|
Parent(s)
|
|
IGNORE email update if value already exists.
modified: freepost/__init__.py
modified: freepost/database.py
commits diff:
03779d5..79b4349
2 files changed,
17 insertions,
3 deletions
—
download
Diffstat
Diff options
+1/-1
M freepost/__init__.py
418
|
418
|
|
if about is None or email is None:
|
419
|
419
|
|
redirect (application.get_url ('user'))
|
420
|
420
|
|
|
421
|
|
- |
# TODO check unique value of emails
|
|
421
|
+ |
# Update user info in the database
|
422
|
422
|
|
database.update_user (user['id'], about, email, False)
|
423
|
423
|
|
|
424
|
424
|
|
redirect (application.get_url ('user'))
|
+16/-2
M freepost/database.py
281
|
281
|
|
def update_user (user_id, about, email, email_notifications):
|
282
|
282
|
|
cursor = db.cursor (MySQLdb.cursors.DictCursor)
|
283
|
283
|
|
|
|
284
|
+ |
# Update user info, but not email address
|
284
|
285
|
|
cursor.execute (
|
285
|
286
|
|
"""
|
286
|
287
|
|
UPDATE user
|
287
|
288
|
|
SET about = %(about)s,
|
288
|
|
- |
email = %(email)s,
|
289
|
289
|
|
email_notifications = %(notifications)s
|
290
|
290
|
|
WHERE id = %(user)s
|
291
|
291
|
|
""",
|
292
|
292
|
|
{
|
293
|
293
|
|
'about': about,
|
294
|
|
- |
'email': email,
|
295
|
294
|
|
'notifications': email_notifications,
|
296
|
295
|
|
'user': user_id
|
297
|
296
|
|
}
|
298
|
297
|
|
)
|
|
298
|
+ |
|
|
299
|
+ |
# Update email address
|
|
300
|
+ |
# IGNORE update if the email address is already specified. This is
|
|
301
|
+ |
# necessary to avoid an "duplicate key" exception when updating value.
|
|
302
|
+ |
cursor.execute (
|
|
303
|
+ |
"""
|
|
304
|
+ |
UPDATE IGNORE user
|
|
305
|
+ |
SET email = %(email)s
|
|
306
|
+ |
WHERE id = %(user)s
|
|
307
|
+ |
""",
|
|
308
|
+ |
{
|
|
309
|
+ |
'email': email,
|
|
310
|
+ |
'user': user_id
|
|
311
|
+ |
}
|
|
312
|
+ |
)
|
299
|
313
|
|
|
300
|
314
|
|
# Set user replies as read
|
301
|
315
|
|
def set_replies_as_read (user_id):
|