mirror of
https://git.wownero.com/wownero/wownero-funding-system.git
synced 2024-08-15 00:53:45 +00:00
Better error handling for user registration, better alerts
This commit is contained in:
parent
40705e5a34
commit
4044c5c644
6 changed files with 38 additions and 18 deletions
|
@ -47,6 +47,24 @@ class User(base):
|
|||
def __repr__(self):
|
||||
return '<User %r>' % self.username
|
||||
|
||||
@classmethod
|
||||
def add(cls, username, password, email):
|
||||
from wowfunding.factory import db_session
|
||||
from wowfunding.validation import val_username, val_email
|
||||
|
||||
try:
|
||||
# validate incoming username/email
|
||||
val_username(username)
|
||||
val_email(email)
|
||||
|
||||
user = User(username, password, email)
|
||||
db_session.add(user)
|
||||
db_session.commit()
|
||||
db_session.flush()
|
||||
return user
|
||||
except Exception as ex:
|
||||
db_session.rollback()
|
||||
raise
|
||||
|
||||
class Proposal(base):
|
||||
__tablename__ = "proposals"
|
||||
|
@ -91,6 +109,8 @@ class Proposal(base):
|
|||
raise Exception('wrong category')
|
||||
self.category = category
|
||||
|
||||
|
||||
|
||||
@property
|
||||
def json(self):
|
||||
return {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue