style: Fix majority of Prospector complaints

Mainly whitespace fixes
This commit is contained in:
James Graham
2020-02-21 17:28:43 +00:00
parent 6d2737b1a6
commit abcfd67f77
5 changed files with 33 additions and 34 deletions

View File

@@ -17,7 +17,7 @@ class PersonForm(forms.ModelForm):
'relationship_targets',
]
class RelationshipForm(forms.ModelForm):
"""
Form to allow users to describe a relationship - includes :class:`RelationshipQuestion`s.
@@ -30,7 +30,7 @@ class RelationshipForm(forms.ModelForm):
'source',
'target',
]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@@ -50,7 +50,6 @@ class RelationshipForm(forms.ModelForm):
# Save answers to relationship questions
for key, value in self.cleaned_data.items():
if key.startswith('question_'):
question_pk = key.split('_')[-1]
answer = models.RelationshipQuestionChoice.objects.get(pk=value)
self.instance.question_answers.add(answer)

View File

@@ -21,7 +21,7 @@ class Person(models.Model):
"""
class Meta:
verbose_name_plural = 'people'
#: User account belonging to this person
user = models.OneToOneField(settings.AUTH_USER_MODEL,
related_name='person',
@@ -44,7 +44,7 @@ class Person(models.Model):
###############################################################
# Data collected for analysis of community makeup and structure
class GenderChoices(TextChoices):
MALE = 'M', _('Male')
FEMALE = 'F', _('Female')
@@ -76,7 +76,7 @@ class Person(models.Model):
return self.relationships_as_source.all().union(
self.relationships_as_target.all()
)
def get_absolute_url(self):
return reverse('people:person.detail', kwargs={'pk': self.pk})
@@ -105,7 +105,7 @@ class RelationshipQuestion(models.Model):
#: Position of this question in the list
order = models.SmallIntegerField(default=0,
blank=False, null=False)
@property
def choices(self) -> typing.List[typing.List[str]]:
"""
@@ -180,7 +180,7 @@ class Relationship(models.Model):
def __str__(self) -> str:
return f'{self.source} -> {self.target}'
@property
def reverse(self):
"""

View File

@@ -21,7 +21,7 @@ class PersonCreateView(CreateView):
def form_valid(self, form):
if 'user' in self.request.GET:
form.instance.user = self.request.user
return super().form_valid(form)
@@ -51,8 +51,8 @@ class ProfileView(DetailView):
except AttributeError:
return self.request.user.person
class PersonUpdateView(UpdateView):
"""
View for updating a :class:`Person` record.
@@ -68,7 +68,7 @@ class RelationshipDetailView(DetailView):
"""
model = models.Relationship
template_name = 'people/relationship/detail.html'
class RelationshipCreateView(CreateView):
"""
@@ -79,12 +79,12 @@ class RelationshipCreateView(CreateView):
model = models.Relationship
template_name = 'people/relationship/create.html'
form_class = forms.RelationshipForm
def get(self, request, *args, **kwargs):
self.person = models.Person.objects.get(pk=self.kwargs.get('person_pk'))
return super().get(request, *args, **kwargs)
def post(self, request, *args, **kwargs):
self.person = models.Person.objects.get(pk=self.kwargs.get('person_pk'))
@@ -97,19 +97,18 @@ class RelationshipCreateView(CreateView):
initial['target'] = self.person
return initial
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['person'] = self.person
return context
def form_valid(self, form):
"""
Form is valid - create :class:`Relationship` and save answers to questions.
"""
self.object = form.save()
return HttpResponseRedirect(self.object.get_absolute_url())
return HttpResponseRedirect(self.object.get_absolute_url())