Skip to content

Commit

Permalink
Rename Profile to Account in UI and docstrings (for #1519) (#1524)
Browse files Browse the repository at this point in the history
  • Loading branch information
jace authored Nov 15, 2022
1 parent 0635915 commit 3dec874
Show file tree
Hide file tree
Showing 61 changed files with 1,403 additions and 1,177 deletions.
2 changes: 1 addition & 1 deletion funnel/forms/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ class AccountForm(forms.Form):
__("Username"),
description=__(
"Single word that can contain letters, numbers and dashes."
" You need a username to have a public profile"
" You need a username to have a public account page"
),
validators=[
forms.validators.DataRequired(),
Expand Down
4 changes: 2 additions & 2 deletions funnel/forms/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


class ProfileSelectField(forms.AutocompleteField):
"""Render an autocomplete field for selecting a profile."""
"""Render an autocomplete field for selecting an account."""

data: Optional[Profile]
widget = forms.Select2Widget()
Expand All @@ -31,7 +31,7 @@ def process_formdata(self, valuelist) -> None:
"""Process incoming form data."""
if valuelist:
self.data = Profile.query.filter(
# Limit to non-suspended (active) profiles. Do not require profile to
# Limit to non-suspended (active) accounts. Do not require account to
# be public as well
Profile.name == valuelist[0],
Profile.is_active,
Expand Down
6 changes: 3 additions & 3 deletions funnel/forms/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class OrganizationForm(forms.Form):
name = forms.AnnotatedTextField(
__("Username"),
description=__(
"A short name for your organization’s profile page."
"A short name for your organization’s account page."
" Single word containing letters, numbers and dashes only."
" Pick something permanent: changing it will break existing links from"
" around the web"
Expand Down Expand Up @@ -87,7 +87,7 @@ def validate_name(self, field) -> None:
_("This name has been taken by another organization")
)
# We're not supposed to get an unknown reason. Flag error to developers.
raise ValueError(f"Unknown profile name validation failure reason: {reason}")
raise ValueError(f"Unknown account name validation failure reason: {reason}")


@Team.forms('main')
Expand All @@ -110,7 +110,7 @@ class TeamForm(forms.Form):
is_public = forms.BooleanField(
__("Make this team public"),
description=__(
"Team members will be listed on the organization’s profile page"
"Team members will be listed on the organization’s account page"
),
default=True,
)
18 changes: 9 additions & 9 deletions funnel/forms/profile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Forms for user and organization profiles."""
"""Forms for user and organization accounts."""

from __future__ import annotations

Expand Down Expand Up @@ -37,10 +37,10 @@ class ProfileForm(OrganizationForm):
description = forms.MarkdownField(
__("Welcome message"),
validators=[forms.validators.Optional()],
description=__("Optional – This message will be shown on the profile page"),
description=__("Optional – This message will be shown on the account’s page"),
)
logo_url = forms.ImgeeField(
label=__("Profile image"),
label=__("Account image"),
validators=[
forms.validators.Optional(),
forms.validators.Length(max=2000),
Expand All @@ -64,32 +64,32 @@ def set_queries(self) -> None:
self.logo_url.profile = self.profile.name

def make_for_user(self):
"""Customise form for a user profile."""
"""Customise form for a user account."""
self.title.label.text = __("Your name")
self.title.description = __(
"Your full name, in the form others can recognise you by"
)
self.tagline.description = __("A brief statement about yourself")
self.name.description = __(
"A short name for mentioning you with @username, and the URL to your"
" profile page. Single word containing letters, numbers and dashes only."
" account’s page. Single word containing letters, numbers and dashes only."
" Pick something permanent: changing it will break existing links from"
" around the web"
)
self.description.label.text = __("More about you")
self.description.description = __(
"Optional – This message will be shown on the profile page"
"Optional – This message will be shown on the account’s page"
)


@Profile.forms('transition')
class ProfileTransitionForm(forms.Form):
"""Form to transition a profile between public and private state."""
"""Form to transition an account between public and private state."""

edit_obj: Profile

transition = forms.SelectField(
__("Profile visibility"), validators=[forms.validators.DataRequired()]
__("Account visibility"), validators=[forms.validators.DataRequired()]
)

def set_queries(self) -> None:
Expand All @@ -109,7 +109,7 @@ class ProfileLogoForm(forms.Form):
profile: Profile

logo_url = forms.ImgeeField(
__("Profile image"),
__("Account image"),
validators=[
forms.validators.Optional(),
forms.validators.Length(max=2000),
Expand Down
10 changes: 5 additions & 5 deletions funnel/forms/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class ProjectLivestreamForm(forms.Form):
class ProjectNameForm(forms.Form):
"""Form to change the URL name of a project."""

# TODO: Add validators for profile and unique name here instead of delegating to
# TODO: Add validators for `profile` and unique name here instead of delegating to
# the view. Also add `set_queries` method to change ``name.prefix``

name = forms.AnnotatedTextField(
Expand All @@ -187,14 +187,14 @@ class ProjectNameForm(forms.Form):
forms.validators.Length(max=Project.__name_length__),
forms.validators.ValidName(
__(
"This URL contains unsupported characters. It can contain"
" lowercase letters, numbers and hyphens only"
"This URL contains unsupported characters. It can contain lowercase"
" letters, numbers and hyphens only"
)
),
AvailableName(),
],
filters=[forms.filters.strip()],
prefix="https://hasgeek.com/<profile>/",
prefix="https://hasgeek.com/<account>/",
render_kw={'autocorrect': 'off', 'autocapitalize': 'off'},
)

Expand Down Expand Up @@ -296,7 +296,7 @@ class ProjectSponsorForm(forms.Form):
"""Form to add or edit a sponsor on a project."""

profile = ProfileSelectField(
__("Profile"),
__("Account"),
autocomplete_endpoint='/api/1/profile/autocomplete',
results_key='profile',
description=__("Choose a sponsor"),
Expand Down
18 changes: 9 additions & 9 deletions funnel/models/membership_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,13 +472,13 @@ def migrate_user( # type: ignore[return]

@declarative_mixin
class ImmutableProfileMembershipMixin(ImmutableMembershipMixin):
"""Support class for immutable memberships for profiles."""
"""Support class for immutable memberships for accounts."""

profile_id: sa.Column[int]

@declared_attr # type: ignore[no-redef]
def profile_id(cls) -> sa.Column[int]: # pylint: disable=no-self-argument
"""Foreign key column to profile table."""
"""Foreign key column to account (nee profile) table."""
return sa.Column(
sa.Integer,
sa.ForeignKey('profile.id', ondelete='CASCADE'),
Expand All @@ -491,7 +491,7 @@ def profile_id(cls) -> sa.Column[int]: # pylint: disable=no-self-argument
def profile( # pylint: disable=no-self-argument
cls,
) -> sa.orm.relationship[Profile]:
"""Profile that is the subject of this membership record."""
"""Account that is the subject of this membership record."""
return immutable(sa.orm.relationship(Profile, foreign_keys=[cls.profile_id]))

subject: Mapped[Profile]
Expand Down Expand Up @@ -546,18 +546,18 @@ def migrate_profile( # type: ignore[return]
cls, old_profile: Profile, new_profile: Profile
) -> OptionalMigratedTables:
"""
Migrate memberhip records from one profile to another.
Migrate memberhip records from one account (nee profile) to another.
If both profiles have active records, they are merged into a new record in the
new profile's favour. All revoked records for the old profile are transferred to
the new profile.
If both accounts have active records, they are merged into a new record in the
new account's favour. All revoked records for the old account are transferred to
the new account.
"""
# Look up all active membership records of the subclass's type for the old
# profile. `cls` here represents the subclass.
# account. `cls` here represents the subclass.
old_profile_records = cls.query.filter(
cls.profile == old_profile, cls.revoked_at.is_(None)
).all()
# Look up all conflicting memberships for the new profile. Limit lookups by
# Look up all conflicting memberships for the new account. Limit lookups by
# parent except when the membership type doesn't have a parent.
if cls.parent_id is not None:
new_profile_records = cls.query.filter(
Expand Down
2 changes: 1 addition & 1 deletion funnel/models/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ class Notification(NoIdMixin, db.Model): # type: ignore[name-defined]
for_private_recipient = False

#: The preference context this notification is being served under. Users may have
#: customized preferences per profile or project
#: customized preferences per account (nee profile) or project
preference_context: db.Model = None # type: ignore[name-defined]

#: Notification type (identifier for subclass of :class:`NotificationType`)
Expand Down
8 changes: 4 additions & 4 deletions funnel/models/notification_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@


class ProfileSubtype(UuidModelType):
"""Model that links to a profile."""
"""Model that links to an account (nee profile)."""

profile: Mapped[Profile]

Expand All @@ -55,18 +55,18 @@ class DocumentHasProject:

@property
def preference_context(self) -> Profile:
"""Return document's project's profile as preference context."""
"""Return document's project's account as preference context."""
return self.document.project.profile


class DocumentHasProfile:
"""Mixin class for documents linked to a profile."""
"""Mixin class for documents linked to an account (nee profile)."""

document: ProfileSubtype

@property
def preference_context(self) -> Profile:
"""Return document's profile as preference context."""
"""Return document's account as preference context."""
return self.document.profile


Expand Down
Loading

0 comments on commit 3dec874

Please sign in to comment.