Skip to content
This repository was archived by the owner on Apr 29, 2022. It is now read-only.

Commit d01f5e4

Browse files
authored
Remove http[s]://twitter.com/ when the attendees give its twitter account. (#1315)
1 parent dda3e1d commit d01f5e4

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

conference/user_panel.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,11 @@ def clean_twitter(self):
467467
data = self.cleaned_data.get("twitter", "")
468468
if data.startswith("@"):
469469
data = data[1:]
470+
471+
# Remove http[s]://twitter.com
472+
if data.startswith(('https://twitter.com', 'http://twitter.com')):
473+
data = data.split('/')[-1]
474+
470475
return data
471476

472477
def resolve_image_settings(self, selected_option, image_url, image):

tests/test_user_panel.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,27 @@ def test_profile_settings_updates_user_data(user_client):
411411
assert payload['bio'] in response.content.decode()
412412

413413

414+
def test_profile_settings_updates_user_twitter(user_client):
415+
url = reverse('user_panel:profile_settings')
416+
417+
payload = dict(
418+
first_name='One',
419+
last_name='Two',
420+
gender='x',
421+
422+
tagline='I am the one',
423+
twitter='https://twitter.com/one',
424+
bio='One to the Two',
425+
)
426+
427+
response = user_client.post(url, data=payload)
428+
assert response.status_code == 200
429+
assert template_used(response, "conference/user_panel/profile_settings.html")
430+
431+
form = response.context_data['profile_form']
432+
assert form.instance.p3_profile.twitter == 'one'
433+
434+
414435
def test_profile_settings_forbids_using_registered_email(user_client):
415436
url = reverse('user_panel:profile_settings')
416437
user = user_client.user

0 commit comments

Comments
 (0)