Skip to content

Commit

Permalink
use get_invite_url from invitation models in sharing views
Browse files Browse the repository at this point in the history
  • Loading branch information
AnishReddyRavula committed Sep 29, 2023
1 parent 01290d4 commit 0b2dbdd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
15 changes: 9 additions & 6 deletions projects/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
from django.urls import reverse
from django.utils.html import format_html

from projects.models import (ChameleonPublication, Funding, Invitation,
Publication, PublicationSource)
from projects.models import (
ChameleonPublication,
Funding,
Invitation,
Publication,
PublicationSource,
)
from projects.views import resend_invitation


Expand Down Expand Up @@ -137,14 +142,12 @@ class InvitationAdmin(admin.ModelAdmin):
"date_accepted",
"status",
]
actions = ['resend_invitation']
actions = ["resend_invitation"]

def invite_link(self, obj):
if obj.status == Invitation.STATUS_ISSUED:
url = obj.get_invite_url()
return format_html(
f'<a href="{url}" target="_blank">Invite Link</a>'
)
return format_html(f'<a href="{url}" target="_blank">Invite Link</a>')
return ""

@admin.display(description="Expiry")
Expand Down
3 changes: 1 addition & 2 deletions projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,7 @@ def get_invite_url(self, request=None):
str
"""
relative_url = reverse(
"projects:accept_invite",
kwargs={"invite_code": self.email_code}
"projects:accept_invite", kwargs={"invite_code": self.email_code}
)
if request:
return request.build_absolute_uri(relative_url)
Expand Down
3 changes: 1 addition & 2 deletions sharing_portal/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from projects.util import get_project_members
from projects.views import (
add_project_invitation,
get_invite_url,
manage_membership_in_scope,
get_project_membership_managers,
is_membership_manager,
Expand Down Expand Up @@ -1023,7 +1022,7 @@ def send_request_decision_mail(request, daypass_request, daypass_project):
)
daypass_request.invitation = invite
daypass_request.save()
url = get_invite_url(request, invite.email_code)
url = invite.get_invite_url(request)
artifact_url = request.build_absolute_uri(
reverse("sharing_portal:detail", args=[artifact["uuid"]])
)
Expand Down

0 comments on commit 0b2dbdd

Please sign in to comment.