Skip to content

Commit e227928

Browse files
committed
More fixes for address changes
1 parent 7690724 commit e227928

17 files changed

Lines changed: 11 additions & 55 deletions

File tree

froide/account/admin.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ class UserAdmin(RecentAuthRequiredAdminMixin, DjangoUserAdmin):
105105
_("Profile info"),
106106
{
107107
"fields": (
108-
"address",
109108
"organization_name",
110109
"organization_url",
111110
"private",

froide/account/api_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class Meta:
6666
class UserFullSerializer(UserEmailDetailSerializer):
6767
class Meta:
6868
model = User
69-
fields = UserEmailDetailSerializer.Meta.fields + ("address",)
69+
fields = UserEmailDetailSerializer.Meta.fields
7070

7171

7272
class ProfileView(views.APIView):

froide/account/export.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ def export_user_data(user):
181181
"first_name",
182182
"last_name",
183183
"email",
184-
"address",
185184
"terms",
186185
"organization",
187186
"organization_url",

froide/account/factories.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,5 @@ class Meta:
2121
last_login = datetime(2000, 1, 1).replace(tzinfo=timezone.utc)
2222
date_joined = datetime(1999, 1, 1).replace(tzinfo=timezone.utc)
2323
private = False
24-
address = "Dummystreet5\n12345 Town"
2524
organization_name = ""
2625
organization_url = ""

froide/account/forms.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
from . import account_email_changed
2727
from .auth import complete_mfa_authenticate_for_method
28-
from .models import AccountBlocklist, User
28+
from .models import User
2929
from .registries import user_extra_registry
3030
from .services import AccountService, get_user_for_email
3131
from .widgets import ConfirmationWidget, PinInputWidget
@@ -97,9 +97,8 @@ class NewUserBaseForm(forms.Form):
9797
field_order = ["first_name", "last_name", "user_email"]
9898

9999
def __init__(self, *args, **kwargs) -> None:
100-
address_required = kwargs.pop("address_required", False)
101100
super().__init__(*args, **kwargs)
102-
if ALLOW_PSEUDONYM and not address_required:
101+
if ALLOW_PSEUDONYM:
103102
self.fields["last_name"].help_text = format_html(
104103
_(
105104
'<a target="_blank" href="{}">You may use a pseudonym if you don\'t need to receive postal messages</a>.'

froide/account/models.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ class User(AbstractBaseUser, PermissionsMixin):
175175
)
176176

177177
private = models.BooleanField(_("Private"), default=False)
178-
#address = models.TextField(_("Address"), blank=True)
179178
terms = models.BooleanField(_("Accepted Terms"), default=True)
180179

181180
profile_text = models.TextField(blank=True)
@@ -264,7 +263,6 @@ def export_csv(cls, queryset, fields=None):
264263
"private",
265264
"date_joined",
266265
"is_staff",
267-
"address",
268266
"terms",
269267
"request_count",
270268
("tags", lambda x: ",".join(str(t) for t in x.tags.all())),
@@ -277,7 +275,6 @@ def as_json(self) -> str:
277275
"id": self.id,
278276
"first_name": self.first_name,
279277
"last_name": self.last_name,
280-
"address": self.address,
281278
"private": self.private,
282279
"email": self.email,
283280
"organization": self.organization_name,
@@ -419,8 +416,7 @@ def __str__(self):
419416

420417
def match_user(self, user: User) -> bool:
421418
return (
422-
self.match_field(user, "address")
423-
or self.match_field(user, "email")
419+
self.match_field(user, "email")
424420
or self.match_content(self.full_name, user.get_full_name())
425421
)
426422

froide/account/services.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def create_user(cls, **data):
8787

8888
user.private = data["private"]
8989

90-
for key in ("address", "organization_name", "organization_url"):
90+
for key in ("organization_name", "organization_url"):
9191
setattr(user, key, data.get(key, ""))
9292

9393
cls.check_against_blocklist(user)
@@ -345,16 +345,10 @@ def get_user_redactions(self, replacements: Optional[Dict[str, str]] = None):
345345
repl = {
346346
"name": str(_("<< Name removed >>")),
347347
"email": str(_("<< Email removed >>")),
348-
"address": str(_("<< Address removed >>")),
349348
}
350349
if replacements is not None:
351350
repl.update(replacements)
352351

353-
if self.user.address:
354-
for line in self.user.address.splitlines():
355-
if line.strip():
356-
yield (line.strip(), repl["address"])
357-
358352
if self.user.email:
359353
yield (self.user.email, repl["email"])
360354

froide/account/templatetags/account_tags.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
def get_user_form(context, address_required=False):
1818
request = context["request"]
1919
if request.user.is_authenticated:
20-
return AddressForm(
21-
initial={"address": request.user.address}, address_required=address_required
22-
)
20+
return NewUserForm(address_required=address_required, request=request)
2321
else:
2422
return NewUserForm(address_required=address_required, request=request)
2523

froide/account/tests/test_account.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ def test_signup(world, client):
138138
response = client.post(reverse("account-signup"), post)
139139
assert response.status_code == 200
140140
post["user_email"] = "horst.porst@example.com"
141-
post["address"] = "MyOwnPrivateStree 5\n31415 Pi-Ville"
142141

143142
response = client.post(reverse("account-signup"), post)
144143

@@ -149,7 +148,6 @@ def test_signup(world, client):
149148
user = User.objects.get(email=post["user_email"])
150149
assert user.first_name == post["first_name"]
151150
assert user.last_name == post["last_name"]
152-
assert user.address == post["address"]
153151
assert mail.outbox[0].to[0] == post["user_email"]
154152

155153
# sign up with email that is not confirmed
@@ -179,7 +177,6 @@ def test_overlong_name_signup(world, client):
179177
"last_name": "Porst" * 6,
180178
"terms": "on",
181179
"user_email": "horst.porst@example.com",
182-
"address": "MyOwnPrivateStree 5\n31415 Pi-Ville",
183180
"time": (datetime.utcnow() - timedelta(seconds=30)).timestamp(),
184181
}
185182
client.logout()
@@ -198,7 +195,6 @@ def test_signup_too_fast(world, client):
198195
"last_name": "Porst",
199196
"terms": "on",
200197
"user_email": "horst.porst@example.com",
201-
"address": "MyOwnPrivateStree 5\n31415 Pi-Ville",
202198
# Signup in less than 5 seconds
203199
"time": (datetime.utcnow() - timedelta(seconds=3)).timestamp(),
204200
}
@@ -215,7 +211,6 @@ def test_signup_same_name(world, client):
215211
"last_name": "Porst",
216212
"terms": "on",
217213
"user_email": "horst.porst@example.com",
218-
"address": "MyOwnPrivateStree 5\n31415 Pi-Ville",
219214
"time": (datetime.utcnow() - timedelta(seconds=30)).timestamp(),
220215
}
221216
response = client.post(reverse("account-signup"), post)
@@ -233,7 +228,6 @@ def test_confirmation_process(world, client):
233228
first_name="Stefan",
234229
last_name="Wehrmeyer",
235230
user_email="sw@example.com",
236-
address="SomeRandomAddress\n11234 Bern",
237231
private=True,
238232
)
239233
AccountService(user).send_confirmation_mail()
@@ -307,7 +301,6 @@ def test_next_link_signup(world, client):
307301
"last_name": "Porst",
308302
"terms": "on",
309303
"user_email": "horst.porst@example.com",
310-
"address": "MyOwnPrivateStree 5\n31415 Pi-Ville",
311304
"next": url,
312305
"time": (datetime.utcnow() - timedelta(seconds=30)).timestamp(),
313306
}
@@ -466,14 +459,10 @@ def test_change_user(world, client):
466459
assert ok
467460
response = client.post(reverse("account-change_user"), data)
468461
assert response.status_code == 302
469-
data["address"] = ""
470462
response = client.post(reverse("account-change_user"), data)
471463
assert response.status_code == 302
472-
data["address"] = "Some Value"
473464
response = client.post(reverse("account-change_user"), data)
474465
assert response.status_code == 302
475-
user = User.objects.get(username="sw")
476-
assert user.address == data["address"]
477466

478467

479468
@pytest.mark.django_db
@@ -582,7 +571,6 @@ def test_change_email(world, client):
582571
response = client.post(
583572
reverse("account-change_user"),
584573
{
585-
"address": "Test",
586574
"email": "not-email",
587575
},
588576
)
@@ -596,22 +584,20 @@ def test_change_email(world, client):
596584
response = client.post(
597585
reverse("account-change_user"),
598586
{
599-
"address": "Test",
600587
"email": "not-email",
601588
},
602589
)
603590
assert response.status_code == 400
604591
assert len(mail.outbox) == 0
605592

606593
response = client.post(
607-
reverse("account-change_user"), {"address": "Test", "email": user.email}
594+
reverse("account-change_user"), {"email": user.email}
608595
)
609596
assert response.status_code == 302
610597
assert len(mail.outbox) == 0
611598
response = client.post(
612599
reverse("account-change_user"),
613600
{
614-
"address": "Test",
615601
"email": new_email,
616602
},
617603
)
@@ -697,7 +683,6 @@ def test_account_delete(world, client):
697683
assert user.last_name == ""
698684
assert user.email is None
699685
assert user.username == "u%s" % user.pk
700-
assert user.address == ""
701686
assert user.organization_name == ""
702687
assert user.organization_url == ""
703688
assert user.private

froide/account/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def delete_undeleted_left_users():
274274
for user in canceled_but_undeleted:
275275
start_cancel_account_process(user)
276276

277-
277+
# shouldn't be used since we don't store addresses for users
278278
def parse_address(address):
279279
match = POSTCODE_RE.search(address)
280280
if match is None:

0 commit comments

Comments
 (0)