mirror of
https://github.com/Southampton-RSG/breccia-mapper.git
synced 2026-03-03 11:27:09 +00:00
@@ -28,6 +28,19 @@
|
||||
<td>
|
||||
<a class="btn btn-sm btn-info"
|
||||
href="{% url 'people:person.detail' pk=person.pk %}">Profile</a>
|
||||
|
||||
{% if person.pk in existing_relationships %}
|
||||
<a class="btn btn-sm btn-warning"
|
||||
style="width: 10rem"
|
||||
href="{% url 'people:person.relationship.create' person_pk=person.pk %}">Update Relationship
|
||||
</a>
|
||||
|
||||
{% else %}
|
||||
<a class="btn btn-sm btn-success"
|
||||
style="width: 10rem"
|
||||
href="{% url 'people:person.relationship.create' person_pk=person.pk %}">New Relationship
|
||||
</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
@@ -30,12 +30,20 @@ class PersonCreateView(LoginRequiredMixin, CreateView):
|
||||
|
||||
|
||||
class PersonListView(LoginRequiredMixin, ListView):
|
||||
"""
|
||||
View displaying a list of :class:`Person` objects - searchable.
|
||||
"""
|
||||
"""View displaying a list of :class:`Person` objects - searchable."""
|
||||
model = models.Person
|
||||
template_name = 'people/person/list.html'
|
||||
|
||||
def get_context_data(self,
|
||||
**kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
context['existing_relationships'] = set(
|
||||
self.request.user.person.relationship_targets.values_list(
|
||||
'pk', flat=True))
|
||||
|
||||
return context
|
||||
|
||||
|
||||
class ProfileView(LoginRequiredMixin, DetailView):
|
||||
"""
|
||||
@@ -45,7 +53,7 @@ class ProfileView(LoginRequiredMixin, DetailView):
|
||||
|
||||
def get_template_names(self) -> typing.List[str]:
|
||||
"""Return template depending on level of access."""
|
||||
if (self.object.user == self.request.user): # or self.request.user.is_superuser:
|
||||
if (self.object.user == self.request.user) or self.request.user.is_superuser:
|
||||
return ['people/person/detail_full.html']
|
||||
|
||||
return ['people/person/detail_partial.html']
|
||||
|
||||
Reference in New Issue
Block a user