SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SciPost
SciPost
Commits
7372593f
Commit
7372593f
authored
1 year ago
by
George Katsikas
Browse files
Options
Downloads
Patches
Plain Diff
fix nomination invitation logic
add checklist step for sending start email
parent
4e18701a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scipost_django/colleges/templates/colleges/_nominations_invitation_checklist.html
+24
-4
24 additions, 4 deletions
...templates/colleges/_nominations_invitation_checklist.html
scipost_django/colleges/views.py
+57
-42
57 additions, 42 deletions
scipost_django/colleges/views.py
with
81 additions
and
46 deletions
scipost_django/colleges/templates/colleges/_nominations_invitation_checklist.html
+
24
−
4
View file @
7372593f
...
...
@@ -31,18 +31,38 @@
{% if invitation.response == 'accepted' or invitation.response == 'postponed' %}
<li
class=
"list-group-item p-2"
>
{% if invitation.nomination.fellowship %}
{% if
not
invitation.nomination.fellowship %}
<span
class=
"text-danger"
>
{% include 'bi/x-square-fill.html' %}
</span>
<span>
This nominee has no associated Fellowship with this college.
</span>
<a
href=
"{% url 'colleges:fellowship_create' contributor_id=invitation.nomination.profile.contributor.id %}"
target=
"_blank"
>
Set up a Fellowship
</a>
<div>
<a
href=
"{% url 'colleges:fellowship_create' contributor_id=invitation.nomination.profile.contributor.id %}"
target=
"_blank"
>
Set up a Fellowship
</a>
</div>
{% else %}
<span
class=
"text-success"
>
{% include 'bi/check-square-fill.html' %}
</span>
<span>
A fellowship has been created from this nomination.
</span>
{% endif %}
</li>
{% if invitation.nomination.fellowship %}
<li
class=
"list-group-item p-2"
>
{% if not start_email_sent %}
<span
class=
"text-primary"
>
{% include 'bi/question-square-fill.html' %}
</span>
<span>
Uncertain whether a nomination start email has been sent.
</span>
<div>
<a
href=
"{% url 'colleges:fellowship_email_start' pk=nomination.fellowship.id %}"
target=
"_blank"
>
Send Fellowship start email
</a>
</div>
{% else %}
<span
class=
"text-success"
>
{% include 'bi/check-square-fill.html' %}
</span>
<span>
Nomination start email has been sent.
</span>
{% endif %}
</li>
{% endif %}
{% endif %}
</ul>
...
...
This diff is collapsed.
Click to expand it.
scipost_django/colleges/views.py
+
57
−
42
View file @
7372593f
...
...
@@ -277,6 +277,16 @@ class FellowshipStartEmailView(PermissionsMixin, MailView):
mail_code
=
"
fellows/email_fellow_fellowship_start
"
success_url
=
reverse_lazy
(
"
colleges:fellowships
"
)
def
form_valid
(
self
,
form
):
"""
Create an event associated to this outgoing email.
"""
event
=
FellowshipNominationEvent
(
nomination
=
self
.
object
.
nomination
,
description
=
"
Fellowship start email sent
"
,
by
=
self
.
request
.
user
.
contributor
,
)
event
.
save
()
return
super
().
form_valid
(
form
)
@login_required
@permission_required
(
"
scipost.can_manage_college_composition
"
,
raise_exception
=
True
)
...
...
@@ -760,8 +770,12 @@ def _hx_nomination_round_remove_voter(request, round_id, voter_id):
def
_hx_nomination_details_contents
(
request
,
nomination_id
):
"""
For (re)loading the details if modified.
"""
nomination
=
get_object_or_404
(
FellowshipNomination
,
pk
=
nomination_id
)
start_email_sent
=
nomination
.
events
.
filter
(
description__contains
=
"
start email sent
"
,
).
exists
()
context
=
{
"
nomination
"
:
nomination
,
"
start_email_sent
"
:
start_email_sent
,
}
return
render
(
request
,
"
colleges/_hx_nomination_details_contents.html
"
,
context
)
...
...
@@ -1031,64 +1045,65 @@ def _hx_fellowship_invitation_update_response(request, invitation_id):
by
=
request
.
user
.
contributor
,
)
nonexpired_fellowship
=
(
Fellowship
.
objects
.
exclude
(
until_date__lte
=
timezone
.
now
().
date
(),
)
.
filter
(
college
=
invitation
.
nomination
.
college
,
contributor
=
invitation
.
nomination
.
profile
.
contributor
,
)
.
order_by
(
"
-start_date
"
)
.
first
()
)
# If the invitation is accepted or postponed, create a Fellowship
if
invitation
.
response
in
[
FellowshipInvitation
.
RESPONSE_ACCEPTED
,
FellowshipInvitation
.
RESPONSE_POSTPONED
,
]:
nonexpired_fellowship
=
(
Fellowship
.
objects
.
exclude
(
until_date__lte
=
timezone
.
now
().
date
(),
)
.
filter
(
college
=
invitation
.
nomination
.
college
,
contributor
=
invitation
.
nomination
.
profile
.
contributor
,
)
.
order_by
(
"
-start_date
"
)
.
first
()
)
# Create a new Fellowship if no object exists
if
not
nonexpired_fellowship
:
start_date
=
invitation
.
postpone_start_to
or
timezone
.
now
()
fellowship
=
Fellowship
.
objects
.
create
(
college
=
invitation
.
nomination
.
college
,
contributor
=
invitation
.
nomination
.
profile
.
contributor
,
start_date
=
timezone
.
now
()
if
invitation
.
response
==
FellowshipInvitation
.
RESPONSE_ACCEPTED
else
invitation
.
postpone_start_to
,
until_date
=
None
,
start_date
=
start_date
,
until_date
=
start_date
+
timezone
.
timedelta
(
days
=
365
*
5
+
1
),
)
invitation
.
nomination
.
add_event
(
description
=
f
"
Fellowship created (start:
{
fellowship
.
start_date
.
strftime
(
'
%Y-%m-%d
'
)
}
)
"
,
by
=
request
.
user
.
contributor
,
)
else
:
# Update the start date of the Fellowship if an object already exists
nonexpired_fellowship
.
start_date
=
(
timezone
.
now
()
if
invitation
.
response
==
FellowshipInvitation
.
RESPONSE_ACCEPTED
else
invitation
.
postpone_start_to
)
nonexpired_fellowship
.
until_date
=
None
invitation
.
nomination
.
add_event
(
description
=
f
"
Fellowship start date updated (start:
{
nonexpired_fellowship
.
start_date
.
strftime
(
'
%Y-%m-%d
'
)
}
)
"
,
by
=
request
.
user
.
contributor
,
)
nonexpired_fellowship
.
save
()
# Terminate the Fellowship if the invitation is declined
elif
invitation
.
response
==
FellowshipInvitation
.
RESPONSE_DECLINED
:
if
nonexpired_fellowship
:
nonexpired_fellowship
.
until_date
=
(
timezone
.
now
().
date
()
if
nonexpired_fellowship
.
is_active
()
else
nonexpired_fellowship
.
start_date
)
invitation
.
nomination
.
add_event
(
description
=
f
"
Fellowship ended (end:
{
nonexpired_fellowship
.
until_date
.
strftime
(
'
%Y-%m-%d
'
)
}
)
"
,
by
=
request
.
user
.
contributor
,
)
nonexpired_fellowship
.
save
()
invitation
.
nomination
.
fellowship
=
fellowship
# else:
# # Update the start date of the Fellowship if an object already exists
# nonexpired_fellowship.start_date = (
# timezone.now()
# if invitation.response == FellowshipInvitation.RESPONSE_ACCEPTED
# else invitation.postpone_start_to
# )
# nonexpired_fellowship.until_date = None
# invitation.nomination.add_event(
# description=f"Fellowship start date updated (start: {nonexpired_fellowship.start_date.strftime('%Y-%m-%d')})",
# by=request.user.contributor,
# )
# nonexpired_fellowship.save()
# # Terminate the Fellowship if the invitation is declined
# elif invitation.response == FellowshipInvitation.RESPONSE_DECLINED:
# if nonexpired_fellowship:
# nonexpired_fellowship.until_date = (
# timezone.now().date()
# if nonexpired_fellowship.is_active()
# else nonexpired_fellowship.start_date
# )
# invitation.nomination.add_event(
# description=f"Fellowship ended (end: {nonexpired_fellowship.until_date.strftime('%Y-%m-%d')})",
# by=request.user.contributor,
# )
# nonexpired_fellowship.save()
return
HTMXResponse
(
f
"
Response updated to:
{
invitation
.
get_response_display
()
}
"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment