mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
models: Add external_account in custom profile field types.
Add new custom profile field type, External account. External account field links user's social media profile with account. e.g. GitHub, Twitter, etc. Fixes part of #12302
This commit is contained in:
committed by
Tim Abbott
parent
3368589df2
commit
d7ee2aced1
@@ -228,6 +228,21 @@ def check_url(var_name: str, val: object) -> Optional[str]:
|
||||
except ValidationError:
|
||||
return _('%s is not a URL') % (var_name,)
|
||||
|
||||
def check_url_pattern(var_name: str, val: object) -> Optional[str]:
|
||||
error = check_string(var_name, val)
|
||||
if error:
|
||||
return error
|
||||
val = cast(str, val)
|
||||
|
||||
if val.count('%(username)s') != 1:
|
||||
return _('username should appear exactly once in pattern.')
|
||||
url_val = val.replace('%(username)s', 'username')
|
||||
|
||||
error = check_url(var_name, url_val)
|
||||
if error:
|
||||
return error
|
||||
return None
|
||||
|
||||
def validate_choice_field_data(field_data: ProfileFieldData) -> Optional[str]:
|
||||
"""
|
||||
This function is used to validate the data sent to the server while
|
||||
|
||||
Reference in New Issue
Block a user