Skip to content

Commit

Permalink
Merge pull request #195 from maykinmedia/task-468-contact-to-message-…
Browse files Browse the repository at this point in the history
…link

[#468] Fix/different emails in admin contact add
  • Loading branch information
annashamray authored May 12, 2022
2 parents 67a42de + 64e424a commit e9235d0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/open_inwoner/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def is_not_active(self) -> bool:
return not self.is_active()

def get_message_url(self) -> str:
url = furl(reverse("accounts:inbox")).add({"with": self.email}).url
url = furl(reverse("accounts:inbox")).add({"with": self.other_user_email}).url
return f"{url}#messages-last"

def get_created_by_name(self):
Expand Down
2 changes: 1 addition & 1 deletion src/open_inwoner/accounts/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def get_extended_contacts_for_user(self, me):
)
.annotate(
other_user_email=Case(
When(created_by=me, then=F("email")),
When(created_by=me, then=F("contact_user__email")),
default=F("created_by__email"),
)
)
Expand Down
8 changes: 7 additions & 1 deletion src/open_inwoner/accounts/tests/test_contact_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,14 @@ def test_contact_filter_without_any_contacts(self):
)

def test_contact_list_show_link_to_messages(self):
other_user = UserFactory()
contact = ContactFactory.create(created_by=self.user, contact_user=other_user)
contacts = Contact.objects.get_extended_contacts_for_user(self.user)
extended_contact = contacts.get(id=contact.id)
message_link = (
furl(reverse("accounts:inbox")).add({"with": self.contact.email}).url
furl(reverse("accounts:inbox"))
.add({"with": extended_contact.other_user_email})
.url
)
response = self.app.get(self.list_url, user=self.user)
self.assertContains(response, message_link)
Expand Down
2 changes: 1 addition & 1 deletion src/open_inwoner/templates/pages/plans/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ <h1 class="h1" id="title">
<p class="plan-contact__info">{{ contact.get_name }}</p>
<p class="plan-contact__info">{{ contact.function }}</p>
<p class="plan-contact__info">{{ contact.phonenumber }}</p>
<p class="plan-contact__info">{{ contact.email }}</p>
<p class="plan-contact__info">{{ contact.contact_user.email }}</p>
{% else %}
<p class="plan-contact__info">{{ contact.get_created_by_name }}</p>
<p class="plan-contact__info">{{ contact.function }}</p>
Expand Down

0 comments on commit e9235d0

Please sign in to comment.