mirror of
https://github.com/Southampton-RSG/breccia-mapper.git
synced 2026-03-03 03:17:07 +00:00
Merge branch 'dev'
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,7 +1,10 @@
|
||||
# IDE files
|
||||
# IDEs
|
||||
.idea/
|
||||
.vscode/
|
||||
|
||||
# Tools
|
||||
.mypy_cache/
|
||||
|
||||
# Runtime
|
||||
/static/
|
||||
venv/
|
||||
|
||||
14
activities/forms.py
Normal file
14
activities/forms.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from django import forms
|
||||
|
||||
from . import models
|
||||
|
||||
|
||||
class ActivityForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = models.Activity
|
||||
fields = [
|
||||
'name',
|
||||
'series',
|
||||
'type',
|
||||
'medium',
|
||||
]
|
||||
18
activities/migrations/0006_activity_attendance_optional.py
Normal file
18
activities/migrations/0006_activity_attendance_optional.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 2.2.10 on 2020-04-02 15:57
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('activities', '0005_shrink_name_fields_to_255'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='activity',
|
||||
name='attendance_list',
|
||||
field=models.ManyToManyField(blank=True, related_name='activities', to='people.Person'),
|
||||
),
|
||||
]
|
||||
@@ -1,4 +1,5 @@
|
||||
from django.db import models
|
||||
from django.urls import reverse
|
||||
|
||||
|
||||
from people import models as people_models
|
||||
@@ -88,7 +89,11 @@ class Activity(models.Model):
|
||||
|
||||
#: Who attended this activity?
|
||||
attendance_list = models.ManyToManyField(people_models.Person,
|
||||
related_name='activities')
|
||||
related_name='activities',
|
||||
blank=True)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('activities:activity.detail', kwargs={'pk': self.pk})
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.name
|
||||
|
||||
29
activities/templates/activities/activity/create.html
Normal file
29
activities/templates/activities/activity/create.html
Normal file
@@ -0,0 +1,29 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item">
|
||||
<a href="{% url 'activities:activity.list' %}">Activities</a>
|
||||
</li>
|
||||
<li class="breadcrumb-item active" aria-current="page">Create</li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<h1>New Activity</h1>
|
||||
|
||||
<hr>
|
||||
|
||||
<form class="form"
|
||||
method="POST">
|
||||
{% csrf_token %}
|
||||
|
||||
{% load bootstrap4 %}
|
||||
{% bootstrap_form form %}
|
||||
|
||||
{% buttons %}
|
||||
<button class="btn btn-success" type="submit">Submit</button>
|
||||
{% endbuttons %}
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
||||
@@ -10,6 +10,8 @@
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<h1>{{ activity.name }}</h1>
|
||||
|
||||
{% if user_is_attending %}
|
||||
<button class="btn btn-danger"
|
||||
onclick="clickCancelAttend();">
|
||||
@@ -39,6 +41,8 @@
|
||||
|
||||
<hr>
|
||||
|
||||
<h2>Attendance</h2>
|
||||
|
||||
<table class="table table-borderless">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
@@ -7,8 +7,13 @@
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<h1>Activities</h1>
|
||||
|
||||
<hr>
|
||||
|
||||
<a class="btn btn-success"
|
||||
href="{% url 'activities:activity.create' %}">New Activity</a>
|
||||
|
||||
<table class="table table-borderless">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<h1>{{ activity_series.name }}</h1>
|
||||
|
||||
<hr>
|
||||
|
||||
<dl>
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<h1>Activity Series</h1>
|
||||
|
||||
<hr>
|
||||
|
||||
<table class="table table-borderless">
|
||||
|
||||
@@ -14,6 +14,10 @@ urlpatterns = [
|
||||
views.ActivitySeriesDetailView.as_view(),
|
||||
name='activity-series.detail'),
|
||||
|
||||
path('activities/create',
|
||||
views.ActivityCreateView.as_view(),
|
||||
name='activity.create'),
|
||||
|
||||
path('activities',
|
||||
views.ActivityListView.as_view(),
|
||||
name='activity.list'),
|
||||
|
||||
@@ -5,12 +5,12 @@ import json
|
||||
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.http import HttpResponse
|
||||
from django.views.generic import DetailView, ListView, View
|
||||
from django.views.generic import CreateView, DetailView, ListView, View
|
||||
from django.views.generic.detail import SingleObjectMixin
|
||||
|
||||
from people import models as people_models
|
||||
from people import permissions
|
||||
from . import models
|
||||
from . import forms, models
|
||||
|
||||
|
||||
class ActivitySeriesListView(LoginRequiredMixin, ListView):
|
||||
@@ -29,6 +29,15 @@ class ActivitySeriesDetailView(LoginRequiredMixin, DetailView):
|
||||
model = models.ActivitySeries
|
||||
template_name = 'activities/activity_series/detail.html'
|
||||
context_object_name = 'activity_series'
|
||||
|
||||
|
||||
class ActivityCreateView(LoginRequiredMixin, CreateView):
|
||||
"""
|
||||
View to create a new instance of :class:`Activity`.
|
||||
"""
|
||||
model = models.Activity
|
||||
template_name = 'activities/activity/create.html'
|
||||
form_class = forms.ActivityForm
|
||||
|
||||
|
||||
class ActivityListView(LoginRequiredMixin, ListView):
|
||||
@@ -65,14 +74,13 @@ class ActivityAttendanceView(permissions.UserIsLinkedPersonMixin, SingleObjectMi
|
||||
def get_test_person(self) -> people_models.Person:
|
||||
data = json.loads(self.request.body)
|
||||
|
||||
self.person = people_models.Person.objects.get(pk=data['pk'])
|
||||
return self.person
|
||||
return people_models.Person.objects.get(pk=data['pk'])
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
self.object = self.get_object()
|
||||
|
||||
if request.is_ajax():
|
||||
self.object.attendance_list.add(self.person)
|
||||
self.object.attendance_list.add(self.get_test_person())
|
||||
|
||||
return HttpResponse(status=204)
|
||||
|
||||
@@ -82,7 +90,7 @@ class ActivityAttendanceView(permissions.UserIsLinkedPersonMixin, SingleObjectMi
|
||||
self.object = self.get_object()
|
||||
|
||||
if request.is_ajax():
|
||||
self.object.attendance_list.remove(self.person)
|
||||
self.object.attendance_list.remove(self.get_test_person())
|
||||
|
||||
return HttpResponse(status=204)
|
||||
|
||||
|
||||
@@ -74,4 +74,3 @@ class ActivityAttendanceSerializer(base.FlattenedModelSerializer):
|
||||
'activity',
|
||||
'person',
|
||||
]
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<h1>Export Data</h1>
|
||||
|
||||
<hr>
|
||||
|
||||
<table class="table table-borderless">
|
||||
|
||||
@@ -14,9 +14,18 @@ class PersonForm(forms.ModelForm):
|
||||
"""
|
||||
class Meta:
|
||||
model = models.Person
|
||||
exclude = [
|
||||
'user',
|
||||
'relationship_targets',
|
||||
fields = [
|
||||
'name',
|
||||
'core_member',
|
||||
'gender',
|
||||
'age_group',
|
||||
'nationality',
|
||||
'country_of_residence',
|
||||
'organisation',
|
||||
'job_title',
|
||||
'discipline',
|
||||
'role',
|
||||
'themes',
|
||||
]
|
||||
widgets = {
|
||||
'nationality': Select2Widget(),
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import typing
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import AbstractUser
|
||||
from django.db import models
|
||||
@@ -28,12 +26,7 @@ class User(AbstractUser):
|
||||
"""
|
||||
Does this user have a linked :class:`Person` record?
|
||||
"""
|
||||
try:
|
||||
person = self.person
|
||||
return True
|
||||
|
||||
except AttributeError:
|
||||
return False
|
||||
return hasattr(self, 'person')
|
||||
|
||||
|
||||
class Organisation(models.Model):
|
||||
@@ -182,5 +175,3 @@ class Person(models.Model):
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.name
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<h1>Network View</h1>
|
||||
|
||||
<hr>
|
||||
|
||||
<form class="form"
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<h1>New Person</h1>
|
||||
|
||||
<hr>
|
||||
|
||||
<form class="form"
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<h1>{{ person }}</h1>
|
||||
<h1>{{ person.name }}</h1>
|
||||
|
||||
<hr>
|
||||
|
||||
<dl>
|
||||
{% if person.gender %}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<h1>People</h1>
|
||||
|
||||
<hr>
|
||||
|
||||
{% if request.user.is_staff %}
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<h1>{{ person.name }}</h1>
|
||||
|
||||
<hr>
|
||||
|
||||
<form class="form"
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<h1>New Relationship</h1>
|
||||
|
||||
<hr>
|
||||
|
||||
<form class="form"
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<h1>Relationship</h1>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="row align-content-center align-items-center">
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<h1>Update Relationship</h1>
|
||||
|
||||
<hr>
|
||||
|
||||
<form class="form"
|
||||
|
||||
Reference in New Issue
Block a user