Skip to content

Commit fd884a4

Browse files
committed
Added "Try again" as a default solution message
1 parent 93c4967 commit fd884a4

File tree

17 files changed

+48
-49
lines changed

17 files changed

+48
-49
lines changed

backend/PyMatcha/models/user.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,15 @@ def create(
110110
# Check correct gender
111111
if gender not in ["male", "female", "other"]:
112112
logging.error("Gender must be male, female or other, not {}".format(gender))
113-
raise ConflictError("Gender must be male, female or other, not {}".format(gender), "Try again")
113+
raise ConflictError("Gender must be male, female or other, not {}".format(gender))
114114

115115
# Check correct orientation
116116
if orientation not in ["heterosexual", "homosexual", "bisexual", "other"]:
117117
logging.error(
118118
"Sexual Orientation must be heterosexual, homosexual, bisexual or other, not {}".format(orientation)
119119
)
120120
raise ConflictError(
121-
"Sexual Orientation must be heterosexual, homosexual, bisexual or other, not {}".format(orientation),
122-
"Try again",
121+
"Sexual Orientation must be heterosexual, homosexual, bisexual or other, not {}".format(orientation)
123122
)
124123

125124
# Check correct geohash
@@ -521,6 +520,6 @@ def get_user(uid: Any[int, str]) -> Optional[User]:
521520
# If none of those worked, throw an error
522521
if not_found == 3:
523522
logging.debug("User {} not found.".format(uid))
524-
raise NotFoundError("User {} not found.".format(uid), "Try again with another uid")
523+
raise NotFoundError("User {} not found.".format(uid))
525524
logging.debug("Found user {} from {}".format(f_user.id, uid))
526525
return f_user

backend/PyMatcha/routes/api/auth/login.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ def auth_login():
5555
u = get_user(username)
5656
except NotFoundError:
5757
current_app.logger.debug("/auth/login -> User not found")
58-
raise UnauthorizedError("Incorrect username or password", "Try again")
58+
raise UnauthorizedError("Incorrect username or password")
5959
if not u.check_password(password):
6060
current_app.logger.debug("/auth/login -> Password invalid")
61-
raise UnauthorizedError("Incorrect username or password", "Try again")
61+
raise UnauthorizedError("Incorrect username or password")
6262

6363
if not u.is_confirmed:
6464
current_app.logger.debug("/auth/login -> User is trying to login unconfirmed")

backend/PyMatcha/routes/api/auth/password.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ def reset_password():
8282
else:
8383
if token_type != "reset":
8484
current_app.logger.debug("/auth/password/reset -> Wrong token type")
85-
raise BadRequestError("Wrong token type", "Try again with the correct type")
85+
raise BadRequestError("Wrong token type")
8686
try:
8787
u = get_user(email)
8888
except NotFoundError:
8989
current_app.logger.debug("/auth/password/reset -> User not found")
90-
raise NotFoundError("User not found", "Try again with another user.")
90+
raise NotFoundError("User not found")
9191
if u.previous_reset_token == data["token"]:
9292
current_app.logger.debug("/auth/password/reset -> Token already used")
9393
raise BadRequestError("Token already used", "Please request a new one")

backend/PyMatcha/routes/api/debug.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def debug_confirm_user(uid):
3535
u = get_user(uid)
3636
except NotFoundError:
3737
current_app.logger.debug("/debug/users/confirm -> User not found")
38-
raise NotFoundError("User {} not found".format(uid), "Check the uid and try again")
38+
raise NotFoundError("User {} not found".format(uid))
3939
if u.is_confirmed:
4040
current_app.logger.debug("/debug/users/confirm -> User already confirmed")
4141
return Success("User already confirmed.")
@@ -53,7 +53,7 @@ def delete_user(uid):
5353
try:
5454
u = get_user(uid)
5555
except NotFoundError:
56-
raise NotFoundError("User {} not found".format(uid), "Check given id and try again")
56+
raise NotFoundError("User {} not found".format(uid))
5757
else:
5858
current_app.logger.info("/debug/users/{} -> DELETE user {}".format(uid, uid))
5959
u.delete()

backend/PyMatcha/routes/api/like.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ def like_profile(uid):
1818
try:
1919
u = get_user(uid)
2020
except NotFoundError:
21-
raise NotFoundError(f"User {uid} not found", "try again")
21+
raise NotFoundError(f"User {uid} not found")
2222
if current_user.id == u.id:
23-
raise BadRequestError("Cannot like yourself", "Try again")
23+
raise BadRequestError("Cannot like yourself")
2424
if current_user.already_likes(u.id):
25-
raise BadRequestError("You already liked this person", "Try again")
25+
raise BadRequestError("You already liked this person")
2626
Like.create(liker_id=current_user.id, liked_id=u.id)
2727

2828
if u.already_likes(current_user.id):
@@ -38,11 +38,11 @@ def unlike_profile(uid):
3838
try:
3939
u = get_user(uid)
4040
except NotFoundError:
41-
raise NotFoundError(f"User {uid} not found", "try again")
41+
raise NotFoundError(f"User {uid} not found")
4242
if current_user.id == u.id:
43-
raise BadRequestError("Cannot unlike yourself", "Try again")
43+
raise BadRequestError("Cannot unlike yourself")
4444
if not current_user.already_likes(u.id):
45-
raise BadRequestError("You never liked this person in the first place", "Try again")
45+
raise BadRequestError("You never liked this person in the first place")
4646
Like.get_multi(liked_id=u.id, liker_id=current_user.id).delete()
4747
return Success(f"Unliked user {u.id}.")
4848

backend/PyMatcha/routes/api/messages.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ def send_message():
6868
try:
6969
to_user = get_user(to_uid)
7070
except NotFoundError:
71-
raise NotFoundError(f"Recipient {to_uid} not found", "Try again")
71+
raise NotFoundError(f"Recipient {to_uid} not found")
7272

7373
if current_user.id == to_user.id:
74-
raise BadRequestError("Cannot send a message to yourself.", "Try again")
74+
raise BadRequestError("Cannot send a message to yourself.")
7575

7676
current_user.send_message(to_id=to_user.id, content=content)
7777
current_app.logger.debug("/messages -> Message successfully sent to {}.".format(to_uid))
@@ -85,7 +85,7 @@ def get_conversation_messsages(with_uid):
8585
try:
8686
with_user = get_user(with_uid)
8787
except NotFoundError:
88-
raise NotFoundError("With user {} not found", "Try again")
88+
raise NotFoundError("With user {} not found")
8989
message_list = current_user.get_messages_with_user(with_user.id)
9090
message_list = [m.to_dict() for m in message_list]
9191
return SuccessOutput("messages", message_list)
@@ -97,7 +97,7 @@ def see_conversation_messages(with_uid):
9797
try:
9898
with_user = get_user(with_uid)
9999
except NotFoundError:
100-
raise NotFoundError(f"With user {with_uid} not found", "Try again")
100+
raise NotFoundError(f"With user {with_uid} not found")
101101
unseen_messages = Message.get_multis(from_id=with_user.id, to_id=current_user.id, is_seen=False)
102102
if unseen_messages:
103103
for message in unseen_messages:
@@ -112,9 +112,9 @@ def like_message(message_id):
112112
try:
113113
message = Message.get(message_id)
114114
except NotFoundError:
115-
raise NotFoundError(f"Message {message_id} not found", "Try again")
115+
raise NotFoundError(f"Message {message_id} not found")
116116
if message.to_id != current_user.id:
117-
raise BadRequestError("Cannot like a message that isn't destined to you", "Try again")
117+
raise BadRequestError("Cannot like a message that isn't destined to you")
118118
message.is_liked = True
119119
message.save()
120120
return Success(f"Liked message {message_id}")

backend/PyMatcha/routes/api/profile/complete.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,22 @@ def complete_profile():
5050
try:
5151
birthdate = datetime.datetime.strptime(birthdate, "%d/%m/%Y").date()
5252
except ValueError:
53-
raise BadRequestError("Birthdate format must be %d/%m/%Y (day/month/year)", "Try again")
53+
raise BadRequestError("Birthdate format must be %d/%m/%Y (day/month/year)")
5454

5555
if len(bio) <= 50:
56-
raise BadRequestError("Bio is too short", "Try again")
56+
raise BadRequestError("Bio is too short")
5757

5858
if len(tags) < 3:
59-
raise BadRequestError("At least 3 tags are required", "Try again")
59+
raise BadRequestError("At least 3 tags are required")
6060

6161
if len(tags) != len(set(tags)):
62-
raise BadRequestError("Duplicate tags", "Try again")
62+
raise BadRequestError("Duplicate tags")
6363

6464
today = datetime.datetime.utcnow()
6565

6666
age = today.year - birthdate.year - ((today.month, today.day) < (birthdate.month, birthdate.day))
6767
if age < 18:
68-
raise BadRequestError("You must be 18 years old or older", "Try again later")
68+
raise BadRequestError("You must be 18 years old or older")
6969

7070
for tag in tags:
7171
Tag.create(name=tag, user_id=current_user.id)

backend/PyMatcha/routes/api/profile/edit.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,26 +69,26 @@ def edit_profile():
6969
try:
7070
birthdate = datetime.datetime.strptime(birthdate, "%d/%m/%Y").date()
7171
except ValueError:
72-
raise BadRequestError("Birthdate format must be %d/%m/%Y (day/month/year)", "Try again")
72+
raise BadRequestError("Birthdate format must be %d/%m/%Y (day/month/year)")
7373

7474
today = datetime.datetime.utcnow()
7575

7676
age = today.year - birthdate.year - ((today.month, today.day) < (birthdate.month, birthdate.day))
7777
if age < 18:
78-
raise BadRequestError("You must be 18 years old or older", "Try again later")
78+
raise BadRequestError("You must be 18 years old or older")
7979

8080
try:
8181
get_user(username)
8282
except NotFoundError:
8383
pass
8484
else:
85-
raise BadRequestError("Username taken", "Try again")
85+
raise BadRequestError("Username taken")
8686

8787
if orientation not in ["heterosexual", "homosexual", "bisexual", "other"]:
88-
raise BadRequestError("Orientation must be heterosexual, homosexual, bisexual or other", "Try again")
88+
raise BadRequestError("Orientation must be heterosexual, homosexual, bisexual or other")
8989

9090
if gender not in ["male", "female", "other"]:
91-
raise BadRequestError("Gender must be male, female or other", "Try again")
91+
raise BadRequestError("Gender must be male, female or other")
9292

9393
current_user.first_name = first_name
9494
current_user.last_name = last_name
@@ -108,7 +108,7 @@ def edit_email():
108108
data = request.get_json()
109109
new_email = data["email"].lower()
110110
if current_user.email == new_email:
111-
raise BadRequestError("The new email is the same as the old one !", "Try again")
111+
raise BadRequestError("The new email is the same as the old one !")
112112
current_user.email = new_email
113113
current_user.is_confirmed = False
114114
current_user.save()
@@ -127,7 +127,7 @@ def edit_password():
127127
old_password = data["old_password"]
128128
new_password = data["new_password"]
129129
if not current_user.check_password(old_password):
130-
raise UnauthorizedError("Incorrect password", "Try again")
130+
raise UnauthorizedError("Incorrect password")
131131
current_user.password = hash_password(new_password)
132132
current_user.save()
133133
send_mail_text.delay(

backend/PyMatcha/routes/api/profile/report.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def report_profile(uid):
3838
reason = data["reason"]
3939

4040
if reason not in ["harassment", "bot", "spam", "inappropriate content"]:
41-
raise BadRequestError("Reason must be 'harassment', 'bot', 'spam' or 'inappropriate content'", "Try again")
41+
raise BadRequestError("Reason must be 'harassment', 'bot', 'spam' or 'inappropriate content'")
4242

4343
try:
4444
details = data["details"]
@@ -47,9 +47,9 @@ def report_profile(uid):
4747
try:
4848
u = get_user(uid)
4949
except NotFoundError:
50-
raise NotFoundError(f"User {uid} not found", "try again")
50+
raise NotFoundError(f"User {uid} not found")
5151
if current_user.id == u.id:
52-
raise BadRequestError("Cannot report yourself", "Try again")
52+
raise BadRequestError("Cannot report yourself")
5353
Report.create(reporter_id=current_user.id, reported_id=u.id, reason=reason, details=details)
5454

5555
return Success(f"Report created on user {u.email}")

backend/PyMatcha/routes/api/profile/view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def view_profile(uid):
4141
try:
4242
u = get_user(uid)
4343
except NotFoundError:
44-
raise NotFoundError(f"User {uid} not found", "try again")
44+
raise NotFoundError(f"User {uid} not found")
4545

4646
if current_user.id != u.id:
4747
View.create(profile_id=u.id, viewer_id=current_user.id)

0 commit comments

Comments
 (0)