mirror of
https://github.com/Southampton-RSG/breccia-mapper.git
synced 2026-03-03 11:27:09 +00:00
@@ -30,7 +30,6 @@ class PersonAnswerSetSerializer(base.FlattenedModelSerializer):
|
|||||||
'organisation',
|
'organisation',
|
||||||
'organisation_started_date',
|
'organisation_started_date',
|
||||||
'job_title',
|
'job_title',
|
||||||
'themes',
|
|
||||||
'latitude',
|
'latitude',
|
||||||
'longitude',
|
'longitude',
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -41,11 +41,6 @@ class OrganisationAdmin(admin.ModelAdmin):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@admin.register(models.Theme)
|
|
||||||
class ThemeAdmin(admin.ModelAdmin):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class PersonQuestionChoiceInline(admin.TabularInline):
|
class PersonQuestionChoiceInline(admin.TabularInline):
|
||||||
model = models.PersonQuestionChoice
|
model = models.PersonQuestionChoice
|
||||||
|
|
||||||
|
|||||||
@@ -163,7 +163,6 @@ class PersonAnswerSetForm(forms.ModelForm, DynamicAnswerSetBase):
|
|||||||
'organisation_started_date',
|
'organisation_started_date',
|
||||||
'project_started_date',
|
'project_started_date',
|
||||||
'job_title',
|
'job_title',
|
||||||
'themes',
|
|
||||||
'latitude',
|
'latitude',
|
||||||
'longitude',
|
'longitude',
|
||||||
]
|
]
|
||||||
@@ -172,7 +171,6 @@ class PersonAnswerSetForm(forms.ModelForm, DynamicAnswerSetBase):
|
|||||||
'country_of_residence': Select2Widget(),
|
'country_of_residence': Select2Widget(),
|
||||||
'organisation_started_date': DatePickerInput(format='%Y-%m-%d'),
|
'organisation_started_date': DatePickerInput(format='%Y-%m-%d'),
|
||||||
'project_started_date': DatePickerInput(format='%Y-%m-%d'),
|
'project_started_date': DatePickerInput(format='%Y-%m-%d'),
|
||||||
'themes': Select2MultipleWidget(),
|
|
||||||
'latitude': forms.HiddenInput,
|
'latitude': forms.HiddenInput,
|
||||||
'longitude': forms.HiddenInput,
|
'longitude': forms.HiddenInput,
|
||||||
}
|
}
|
||||||
|
|||||||
39
people/migrations/0044_themes_to_admin_question.py
Normal file
39
people/migrations/0044_themes_to_admin_question.py
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# Generated by Django 2.2.10 on 2021-03-10 09:05
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
from .utils.question_sets import port_question
|
||||||
|
|
||||||
|
|
||||||
|
def migrate_forward(apps, schema_editor):
|
||||||
|
# Make question
|
||||||
|
Theme = apps.get_model('people', 'Theme')
|
||||||
|
theme_question = port_question(
|
||||||
|
apps, 'Research theme affiliation',
|
||||||
|
Theme.objects.all().values_list('name', flat=True),
|
||||||
|
is_multiple_choice=True)
|
||||||
|
|
||||||
|
PersonAnswerSet = apps.get_model('people', 'PersonAnswerSet')
|
||||||
|
for answerset in PersonAnswerSet.objects.all():
|
||||||
|
for theme in answerset.themes.all():
|
||||||
|
answerset.question_answers.add(
|
||||||
|
theme_question.answers.get(text=theme.name)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('people', '0043_organisationanswerset_is_partner_organisation'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(migrate_forward),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='personanswerset',
|
||||||
|
name='themes',
|
||||||
|
),
|
||||||
|
migrations.DeleteModel(
|
||||||
|
name='Theme',
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -18,7 +18,6 @@ logger = logging.getLogger(__name__) # pylint: disable=invalid-name
|
|||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'User',
|
'User',
|
||||||
'Theme',
|
|
||||||
'PersonQuestion',
|
'PersonQuestion',
|
||||||
'PersonQuestionChoice',
|
'PersonQuestionChoice',
|
||||||
'Person',
|
'Person',
|
||||||
@@ -66,16 +65,6 @@ class User(AbstractUser):
|
|||||||
self.username)
|
self.username)
|
||||||
|
|
||||||
|
|
||||||
class Theme(models.Model):
|
|
||||||
"""
|
|
||||||
Project theme within which a :class:`Person` works.
|
|
||||||
"""
|
|
||||||
name = models.CharField(max_length=255, blank=False, null=False)
|
|
||||||
|
|
||||||
def __str__(self) -> str:
|
|
||||||
return self.name
|
|
||||||
|
|
||||||
|
|
||||||
class PersonQuestion(Question):
|
class PersonQuestion(Question):
|
||||||
"""Question which may be asked about a person."""
|
"""Question which may be asked about a person."""
|
||||||
|
|
||||||
@@ -180,9 +169,6 @@ class PersonAnswerSet(AnswerSet):
|
|||||||
blank=True,
|
blank=True,
|
||||||
null=False)
|
null=False)
|
||||||
|
|
||||||
#: Project themes within this person works
|
|
||||||
themes = models.ManyToManyField(Theme, related_name='people', blank=True)
|
|
||||||
|
|
||||||
#: Latitude for displaying location on a map
|
#: Latitude for displaying location on a map
|
||||||
latitude = models.FloatField(blank=True, null=True)
|
latitude = models.FloatField(blank=True, null=True)
|
||||||
|
|
||||||
|
|||||||
@@ -31,17 +31,6 @@
|
|||||||
<tr><td>Job Title</td><td>{{ answer_set.job_title }}</td></tr>
|
<tr><td>Job Title</td><td>{{ answer_set.job_title }}</td></tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if answer_set.themes.exists %}
|
|
||||||
<tr>
|
|
||||||
<td>Project Themes</td>
|
|
||||||
<td>
|
|
||||||
{% for theme in answer_set.themes.all %}
|
|
||||||
{{ theme }}{% if not forloop.last %}, {% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% for answer in answer_set.question_answers.all %}
|
{% for answer in answer_set.question_answers.all %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ answer.question }}</td>
|
<td>{{ answer.question }}</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user