mirror of
https://github.com/Southampton-RSG/breccia-mapper.git
synced 2026-03-03 11:27:09 +00:00
Merge branch 'dev'
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,7 +1,10 @@
|
|||||||
# IDE files
|
# IDEs
|
||||||
.idea/
|
.idea/
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
|
# Tools
|
||||||
|
.mypy_cache/
|
||||||
|
|
||||||
# Runtime
|
# Runtime
|
||||||
/static/
|
/static/
|
||||||
venv/
|
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.db import models
|
||||||
|
from django.urls import reverse
|
||||||
|
|
||||||
|
|
||||||
from people import models as people_models
|
from people import models as people_models
|
||||||
@@ -88,7 +89,11 @@ class Activity(models.Model):
|
|||||||
|
|
||||||
#: Who attended this activity?
|
#: Who attended this activity?
|
||||||
attendance_list = models.ManyToManyField(people_models.Person,
|
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:
|
def __str__(self) -> str:
|
||||||
return self.name
|
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>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
<h1>{{ activity.name }}</h1>
|
||||||
|
|
||||||
{% if user_is_attending %}
|
{% if user_is_attending %}
|
||||||
<button class="btn btn-danger"
|
<button class="btn btn-danger"
|
||||||
onclick="clickCancelAttend();">
|
onclick="clickCancelAttend();">
|
||||||
@@ -39,6 +41,8 @@
|
|||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
|
<h2>Attendance</h2>
|
||||||
|
|
||||||
<table class="table table-borderless">
|
<table class="table table-borderless">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -7,8 +7,13 @@
|
|||||||
</ol>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
<h1>Activities</h1>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
|
<a class="btn btn-success"
|
||||||
|
href="{% url 'activities:activity.create' %}">New Activity</a>
|
||||||
|
|
||||||
<table class="table table-borderless">
|
<table class="table table-borderless">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
</ol>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
<h1>{{ activity_series.name }}</h1>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<dl>
|
<dl>
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
</ol>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
<h1>Activity Series</h1>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<table class="table table-borderless">
|
<table class="table table-borderless">
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ urlpatterns = [
|
|||||||
views.ActivitySeriesDetailView.as_view(),
|
views.ActivitySeriesDetailView.as_view(),
|
||||||
name='activity-series.detail'),
|
name='activity-series.detail'),
|
||||||
|
|
||||||
|
path('activities/create',
|
||||||
|
views.ActivityCreateView.as_view(),
|
||||||
|
name='activity.create'),
|
||||||
|
|
||||||
path('activities',
|
path('activities',
|
||||||
views.ActivityListView.as_view(),
|
views.ActivityListView.as_view(),
|
||||||
name='activity.list'),
|
name='activity.list'),
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ import json
|
|||||||
|
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.http import HttpResponse
|
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 django.views.generic.detail import SingleObjectMixin
|
||||||
|
|
||||||
from people import models as people_models
|
from people import models as people_models
|
||||||
from people import permissions
|
from people import permissions
|
||||||
from . import models
|
from . import forms, models
|
||||||
|
|
||||||
|
|
||||||
class ActivitySeriesListView(LoginRequiredMixin, ListView):
|
class ActivitySeriesListView(LoginRequiredMixin, ListView):
|
||||||
@@ -31,6 +31,15 @@ class ActivitySeriesDetailView(LoginRequiredMixin, DetailView):
|
|||||||
context_object_name = 'activity_series'
|
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):
|
class ActivityListView(LoginRequiredMixin, ListView):
|
||||||
"""
|
"""
|
||||||
View displaying a list of :class:`Activity`.
|
View displaying a list of :class:`Activity`.
|
||||||
@@ -65,14 +74,13 @@ class ActivityAttendanceView(permissions.UserIsLinkedPersonMixin, SingleObjectMi
|
|||||||
def get_test_person(self) -> people_models.Person:
|
def get_test_person(self) -> people_models.Person:
|
||||||
data = json.loads(self.request.body)
|
data = json.loads(self.request.body)
|
||||||
|
|
||||||
self.person = people_models.Person.objects.get(pk=data['pk'])
|
return people_models.Person.objects.get(pk=data['pk'])
|
||||||
return self.person
|
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
self.object = self.get_object()
|
self.object = self.get_object()
|
||||||
|
|
||||||
if request.is_ajax():
|
if request.is_ajax():
|
||||||
self.object.attendance_list.add(self.person)
|
self.object.attendance_list.add(self.get_test_person())
|
||||||
|
|
||||||
return HttpResponse(status=204)
|
return HttpResponse(status=204)
|
||||||
|
|
||||||
@@ -82,7 +90,7 @@ class ActivityAttendanceView(permissions.UserIsLinkedPersonMixin, SingleObjectMi
|
|||||||
self.object = self.get_object()
|
self.object = self.get_object()
|
||||||
|
|
||||||
if request.is_ajax():
|
if request.is_ajax():
|
||||||
self.object.attendance_list.remove(self.person)
|
self.object.attendance_list.remove(self.get_test_person())
|
||||||
|
|
||||||
return HttpResponse(status=204)
|
return HttpResponse(status=204)
|
||||||
|
|
||||||
|
|||||||
@@ -74,4 +74,3 @@ class ActivityAttendanceSerializer(base.FlattenedModelSerializer):
|
|||||||
'activity',
|
'activity',
|
||||||
'person',
|
'person',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
</ol>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
<h1>Export Data</h1>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<table class="table table-borderless">
|
<table class="table table-borderless">
|
||||||
|
|||||||
@@ -14,9 +14,18 @@ class PersonForm(forms.ModelForm):
|
|||||||
"""
|
"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Person
|
model = models.Person
|
||||||
exclude = [
|
fields = [
|
||||||
'user',
|
'name',
|
||||||
'relationship_targets',
|
'core_member',
|
||||||
|
'gender',
|
||||||
|
'age_group',
|
||||||
|
'nationality',
|
||||||
|
'country_of_residence',
|
||||||
|
'organisation',
|
||||||
|
'job_title',
|
||||||
|
'discipline',
|
||||||
|
'role',
|
||||||
|
'themes',
|
||||||
]
|
]
|
||||||
widgets = {
|
widgets = {
|
||||||
'nationality': Select2Widget(),
|
'nationality': Select2Widget(),
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import typing
|
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.models import AbstractUser
|
from django.contrib.auth.models import AbstractUser
|
||||||
from django.db import models
|
from django.db import models
|
||||||
@@ -28,12 +26,7 @@ class User(AbstractUser):
|
|||||||
"""
|
"""
|
||||||
Does this user have a linked :class:`Person` record?
|
Does this user have a linked :class:`Person` record?
|
||||||
"""
|
"""
|
||||||
try:
|
return hasattr(self, 'person')
|
||||||
person = self.person
|
|
||||||
return True
|
|
||||||
|
|
||||||
except AttributeError:
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
class Organisation(models.Model):
|
class Organisation(models.Model):
|
||||||
@@ -182,5 +175,3 @@ class Person(models.Model):
|
|||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
</ol>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
<h1>Network View</h1>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<form class="form"
|
<form class="form"
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
</ol>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
<h1>New Person</h1>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<form class="form"
|
<form class="form"
|
||||||
|
|||||||
@@ -10,7 +10,9 @@
|
|||||||
</ol>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<h1>{{ person }}</h1>
|
<h1>{{ person.name }}</h1>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
<dl>
|
<dl>
|
||||||
{% if person.gender %}
|
{% if person.gender %}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
</ol>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
<h1>People</h1>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
{% if request.user.is_staff %}
|
{% if request.user.is_staff %}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
</ol>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
<h1>{{ person.name }}</h1>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<form class="form"
|
<form class="form"
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
</ol>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
<h1>New Relationship</h1>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<form class="form"
|
<form class="form"
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
</ol>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
<h1>Relationship</h1>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<div class="row align-content-center align-items-center">
|
<div class="row align-content-center align-items-center">
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
</ol>
|
</ol>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
<h1>Update Relationship</h1>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<form class="form"
|
<form class="form"
|
||||||
|
|||||||
Reference in New Issue
Block a user