GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ThreadReplyForm   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
dl 0
loc 14
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A save() 0 10 2
1
from django import forms
2
3
from simple_forums import models
4
5
6
class ThreadCreationForm(forms.Form):
7
    """ Form for creating new threads """
8
    topic = forms.ModelChoiceField(queryset=models.Topic.objects.all())
9
    title = forms.CharField(max_length=200)
10
    body = forms.CharField(label='Post Body', widget=forms.Textarea)
11
12
    def save(self, user):
13
        """ Save the contents of the form.
14
15
        Uses the title field to create a new thread, and uses the body
16
        field to create a new message associated with the created
17
        thread.
18
        """
19
        if self.is_valid():
20
21
            topic = self.cleaned_data['topic']
22
23
            thread = models.Thread.objects.create(
24
                topic=topic,
25
                title=self.cleaned_data['title'])
26
27
            models.Message.objects.create(
28
                user=user,
29
                thread=thread,
30
                body=self.cleaned_data['body'])
31
32
            return thread
33
34
35
class ThreadReplyForm(forms.Form):
36
    """ Form for replying to threads """
37
    body = forms.CharField(label='Reply', widget=forms.Textarea)
38
39
    def save(self, user, thread):
40
        """ Save the contents of the form.
41
42
        Creates a new reply on the given thread by the given user.
43
        """
44
        if self.is_valid():
45
            return models.Message.objects.create(
46
                user=user,
47
                thread=thread,
48
                body=self.cleaned_data['body'])
49