Coverage for src/couchers/urls.py: 94%

62 statements  

« prev     ^ index     » next       coverage.py v7.5.0, created at 2024-07-22 17:19 +0000

1# The source of truth for URLs is 

2# //docs/urls.md 

3# Please make sure this file stays in sync with that file as well as 

4# //app/web/src/routes.ts 

5 

6 

7from couchers.config import config 

8 

9 

10def app_link(): 

11 return f"{config['BASE_URL']}/" 

12 

13 

14def icon_url(): 

15 return f"{config['BASE_URL']}/logo512.png" 

16 

17 

18def profile_link(): 

19 return f"{config['BASE_URL']}/profile" 

20 

21 

22def user_link(*, username): 

23 return f"{config['BASE_URL']}/user/{username}" 

24 

25 

26def edit_profile_link(): 

27 return f"{config['BASE_URL']}/profile/edit" 

28 

29 

30def signup_link(*, token): 

31 return f"{config['BASE_URL']}/signup?token={token}" 

32 

33 

34def login_link(*, login_token): 

35 return f"{config['BASE_URL']}/login?token={login_token}" 

36 

37 

38def account_settings_link(): 

39 return f"{config['BASE_URL']}/account-settings" 

40 

41 

42def feature_preview_link(): 

43 return f"{config['BASE_URL']}/preview" 

44 

45 

46def password_reset_link(*, password_reset_token): 

47 return f"{config['BASE_URL']}/complete-password-reset?token={password_reset_token}" 

48 

49 

50def host_request_link_host(): 

51 return f"{config['BASE_URL']}/messages/hosting/" 

52 

53 

54def host_request_link_guest(): 

55 return f"{config['BASE_URL']}/messages/surfing/" 

56 

57 

58def host_request(*, host_request_id): 

59 return f"{config['BASE_URL']}/messages/request/{host_request_id}" 

60 

61 

62def messages_link(): 

63 return f"{config['BASE_URL']}/messages/" 

64 

65 

66def chat_link(*, chat_id): 

67 return f"{config['BASE_URL']}/messages/chats/{chat_id}" 

68 

69 

70def event_link(*, occurrence_id, slug="e"): 

71 return f"{config['BASE_URL']}/event/{occurrence_id}/{slug}" 

72 

73 

74def community_link(*, node_id, slug="e"): 

75 return f"{config['BASE_URL']}/community/{node_id}/{slug}" 

76 

77 

78def leave_reference_link(*, reference_type, to_user_id, host_request_id=None): 

79 assert reference_type in ["friend", "surfed", "hosted"] 

80 if host_request_id: 

81 return f"{config['BASE_URL']}/leave-reference/{reference_type}/{to_user_id}/{host_request_id}" 

82 else: 

83 return f"{config['BASE_URL']}/leave-reference/{reference_type}/{to_user_id}" 

84 

85 

86def profile_references_link(): 

87 return f"{config['BASE_URL']}/profile/references" 

88 

89 

90def friend_requests_link(): 

91 return f"{config['BASE_URL']}/connections/friends/" 

92 

93 

94def media_upload_url(*, path): 

95 return f"{config['MEDIA_SERVER_BASE_URL']}/{path}" 

96 

97 

98def change_email_link(*, confirmation_token): 

99 return f"{config['BASE_URL']}/confirm-email?token={confirmation_token}" 

100 

101 

102def donation_cancelled_url(): 

103 return f"{config['BASE_URL']}/donate?cancelled=true" 

104 

105 

106def donation_success_url(): 

107 return f"{config['BASE_URL']}/donate?success=true" 

108 

109 

110def delete_account_link(*, account_deletion_token): 

111 return f"{config['BASE_URL']}/delete-account?token={account_deletion_token}" 

112 

113 

114def recover_account_link(*, account_undelete_token): 

115 return f"{config['BASE_URL']}/recover-account?token={account_undelete_token}" 

116 

117 

118def unsubscribe_link(*, payload, sig): 

119 return f"{config['BASE_URL']}/unsubscribe?payload={payload}&sig={sig}" 

120 

121 

122def media_url(*, filename, size): 

123 return f"{config['MEDIA_SERVER_BASE_URL']}/img/{size}/{filename}" 

124 

125 

126def console_link(*, page): 

127 return f"{config['CONSOLE_BASE_URL']}/{page}"