Skip to content

UI fixes #743

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,20 +180,17 @@ <h3 class="d-inline"><i class="fas fa-info-circle" aria-hidden="true"></i> Alloc
<h3 class="d-inline"><i class="fas fa-info-circle" aria-hidden="true"></i> Actions</h3>
</div>
<div class="card-body">


{% csrf_token %}
{{note_form.notes | as_crispy_field}}
<div style="float: right;">
{% if allocation_change.status.name == 'Pending' %}
<button type="submit" name="action" value="approve" class="btn btn-success mr-1">Approve</button>
<button type="submit" name="action" value="deny" class="btn btn-danger mr-1">Deny</button>
{% endif %}
<button type="submit" name="action" value="update" class="btn btn-primary float-right">
<i class="fas fa-sync" aria-hidden="true"></i> Update
</button>
</div>
</div>
{% csrf_token %}
{{note_form.notes | as_crispy_field}}
<div class="d-inline float-right">
{% if allocation_change.status.name == 'Pending' %}
<button type="submit" name="action" value="approve" class="btn btn-success float-right">Approve</button>
<button type="submit" name="action" value="deny" class="btn btn-danger float-right">Deny</button>
{% endif %}
<button type="submit" name="action" value="update" class="btn btn-primary float-right">
<i class="fas fa-sync" aria-hidden="true"></i> Update
</button>
</div>
</div>
</div>
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,13 @@ <h4 class="card-title">{{attribute}}</h4>
<div class="card mb-3">
<div class="card-header">
<h3 class="d-inline"><i class="fas fa-info-circle" aria-hidden="true"></i> Allocation Change Requests</h3> <span class="badge badge-secondary">{{allocation_changes.count}}</span>
<div class="float-right">
{% if request.user.is_superuser and allocation.is_changeable and not allocation.is_locked and is_allowed_to_update_project and allocation.status.name in 'Active, Renewal Requested, Payment Pending, Payment Requested, Paid' %}
<a class="btn btn-primary float-right" href="{% url 'allocation-change' allocation.pk %}" role="button">
Request Change
</a>
{% endif %}
</div>
</div>

<div class="card-body">
Expand Down Expand Up @@ -305,7 +312,9 @@ <h3 class="d-inline"><i class="fas fa-info-circle" aria-hidden="true"></i> Alloc
{% else %}
<td></td>
{% endif %}
<td><a href="{% url 'allocation-change-detail' change_request.pk %}"><i class="far fa-edit" aria-hidden="true"></i><span class="sr-only">Edit</span></a></td>
{% if can_edit_allocation_changes %}
<td><a href="{% url 'allocation-change-detail' change_request.pk %}"><i class="far fa-edit" aria-hidden="true"></i><span class="sr-only">Edit</span></a></td>
{% endif %}
</tr>
{% endfor %}
</tbody>
Expand Down Expand Up @@ -470,4 +479,4 @@ <h3 class="d-inline"><i class="fas fa-users" aria-hidden="true"></i> Notificatio
}
})
</script>
{% endblock %}
{% endblock %}
6 changes: 6 additions & 0 deletions coldfront/core/allocation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ def get_context_data(self, **kwargs):
context["is_allowed_to_update_project"] = allocation_obj.project.has_perm(
self.request.user, ProjectPermission.UPDATE
)
# Can the user edit allocation change requests?
# condition was taken from core.allocation.views.AllocationChangeDetailView;
# maybe better to make a static method that test_func() in that class will call?
context["can_edit_allocation_changes"] = self.request.user.has_perm(
"allocation.can_view_all_allocations"
) or allocation_obj.has_perm(self.request.user, AllocationPermission.MANAGER)

noteset = allocation_obj.allocationusernote_set
notes = noteset.all() if self.request.user.is_superuser else noteset.filter(is_private=False)
Expand Down
6 changes: 3 additions & 3 deletions coldfront/core/project/templates/project/project_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ <h3 class="d-inline" id="research_outputs"><i class="far fa-newspaper" aria-hidd
<!-- Start Admin Messages -->
<div class="card mb-3">
<div class="card-header">
<h3 class="d-inline"><i class="fas fa-users" aria-hidden="true"></i> Notifications </h3> <span class="badge badge-secondary">{{project.projectusermessage_set.count}}</span>
<h3 class="d-inline"><i class="fas fa-users" aria-hidden="true"></i> Notifications </h3> <span class="badge badge-secondary">{{notes.count}}</span>
<div class="float-right">
{% if request.user.is_superuser %}
<a class="btn btn-success" href="{% url 'project-note-add' project.pk %}" role="button">
Expand All @@ -489,7 +489,7 @@ <h3 class="d-inline"><i class="fas fa-users" aria-hidden="true"></i> Notificatio
</div>
</div>
<div class="card-body">
{% if project.projectusermessage_set.all %}
{% if notes %}
<div class="table-responsive">
<table class="table table-hover">
<thead>
Expand All @@ -500,7 +500,7 @@ <h3 class="d-inline"><i class="fas fa-users" aria-hidden="true"></i> Notificatio
</tr>
</thead>
<tbody>
{% for message in project.projectusermessage_set.all %}
{% for message in notes %}
{% if not message.is_private or request.user.is_superuser %}
<tr>
<td>{{ message.message }}</td>
Expand Down
3 changes: 3 additions & 0 deletions coldfront/core/project/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ def get_context_data(self, **kwargs):
if allocation.allocationuser_set.filter(user=self.request.user).exists():
user_status.append(allocation.allocationuser_set.get(user=self.request.user).status.name)

note_set = project_obj.projectusermessage_set
notes = note_set.all() if self.request.user.is_superuser else note_set.filter(is_private=False)
context["notes"] = notes
context["publications"] = Publication.objects.filter(project=self.object, status="Active").order_by("-year")
context["research_outputs"] = ResearchOutput.objects.filter(project=self.object).order_by("-created")
context["grants"] = Grant.objects.filter(
Expand Down