Conditions | 2 |
Total Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | from django import forms |
||
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 | |||
49 |