~chipaca/unity-lens-video/custom-user-agent

« back to all changes in this revision

Viewing changes to main/forms.py

  • Committer: Janos Gyerik
  • Date: 2011-08-07 19:28:15 UTC
  • Revision ID: janos@axiom-20110807192815-74cbfd0u9dw782c7
added primitive account creation and login

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
''' Kind reminders, (please review before editing!)
2
 
    - Forms are for validating input, NOT business logic.
3
 
    - Only include model specific logic in forms if it is required for input.
4
 
      Example: user should be able to select only the groups it is member of.
5
 
    '''
6
 
 
7
 
from django import forms
8
 
 
9
 
from bashoneliners.main.models import OneLiner
10
 
 
11
 
''' constants '''
12
 
 
13
 
#
14
 
 
15
 
 
16
 
''' forms '''
17
 
 
18
 
class PostOneLinerForm(forms.ModelForm):
19
 
    def save(self, hacker):
20
 
        self.instance.hacker = hacker
21
 
        return super(PostOneLinerForm, self).save()
22
 
 
23
 
    class Meta:
24
 
        model = OneLiner
25
 
 
26
 
        widgets = {
27
 
                'line': forms.Textarea(attrs={'cols': 80, 'rows': 3, }),
28
 
                'summary': forms.Textarea(attrs={'cols': 80, 'rows': 3, }),
29
 
                'explanation': forms.Textarea(attrs={'cols': 80, 'rows': 10, }),
30
 
                'caveats': forms.Textarea(attrs={'cols': 80, 'rows': 3, }),
31
 
                }
32
 
 
33
 
        fields = (
34
 
                'line',
35
 
                'summary',
36
 
                'explanation',
37
 
                'caveats',
38
 
                'is_published',
39
 
                )
40
 
 
41
 
 
42
 
# eof