def clean(self): cleaned_data = super(LinkCreate, self).clean() profile = self.cleaned_data["profile"] site = self.cleaned_data["site"] if control.site_link_exists(self.account, site): raise ValidationError(_("ERROR_LINK_PROFILE_FOR_SITE_EXISTS")) if not link_control.valid_profile_format(profile, site): raise ValidationError(_("ERROR_BAD_PROFILE_FORMAT")) if not control.can_create_link(self.account, site, profile): raise ValidationError(_("ERROR_CANNOT_CREATE_LINK")) return cleaned_data
def clean(self): cleaned_data = super(LinkCreate, self).clean() profile = self.cleaned_data["profile"] site = self.cleaned_data["site"] if control.site_link_exists(self.team, site): raise ValidationError(_("ERROR_LINK_PROFILE_FOR_SITE_EXISTS")) if not link_control.valid_profile_format(profile, site): raise ValidationError(_("ERROR_BAD_PROFILE_FORMAT")) if not control.can_create_link(self.account, self.team, site, profile): raise ValidationError(_("ERROR_CANNOT_CREATE_LINK")) return cleaned_data
def can_create_link(account, team, site, profile): return (link_control.valid_profile_format(profile, site) and not site_link_exists(team, site) and is_member(account, team))
def can_create_link(account, team, site, profile): return (link_control.valid_profile_format(profile, site) and not site_link_exists(team, site) and is_member(account, team))
def test_couchsurfing_com_links(self): """ Tests that .com urls are accepted """ self.assertEqual(True, link_control.valid_profile_format("https://couchsurfing.com/people/deivid_rodriguez", "COUCHSURFING"))
def can_create_link(account, site, profile): exists = site_link_exists(account, site) return link_control.valid_profile_format(profile, site) and not exists
def can_create_link(account, site, profile): exists = site_link_exists(account, site) return link_control.valid_profile_format(profile, site) and not exists