@@ -16,22 +16,22 @@ def clean_name(self):
16
16
potential_slug = slugify (name )
17
17
if Project .objects .filter (slug = potential_slug ).count ():
18
18
raise forms .ValidationError ('A project with that name exists already!' )
19
-
19
+
20
20
return name
21
21
22
22
23
23
class CreateProjectForm (ProjectForm ):
24
24
class Meta :
25
25
model = Project
26
- exclude = ('skip' , 'whitelisted' , ' user' , 'slug' , 'repo' ,
26
+ exclude = ('skip' , 'user' , 'slug' , 'repo' ,
27
27
'docs_directory' , 'status' , 'repo_type' )
28
28
29
29
def save (self , * args , ** kwargs ):
30
30
created = self .instance .pk is None
31
-
31
+
32
32
# save the project
33
33
project = super (CreateProjectForm , self ).save (* args , ** kwargs )
34
-
34
+
35
35
if created :
36
36
# create a couple sample files
37
37
for i , (sample_file , template ) in enumerate (constants .SAMPLE_FILES ):
@@ -42,10 +42,10 @@ def save(self, *args, **kwargs):
42
42
ordering = i + 1 ,
43
43
)
44
44
file .create_revision (old_content = '' , comment = '' )
45
-
45
+
46
46
# kick off the celery job
47
47
update_docs .delay (pk = project .pk )
48
-
48
+
49
49
return project
50
50
51
51
@@ -54,8 +54,8 @@ class ImportProjectForm(ProjectForm):
54
54
help_text = 'URL for your code (hg or git). Ex. http://github.com/ericholscher/django-kong.git' )
55
55
class Meta :
56
56
model = Project
57
- exclude = ('skip' , 'whitelisted' , ' theme' , 'docs_directory' , 'user' , 'slug' , 'version' , 'copyright' , 'status' )
58
-
57
+ exclude = ('skip' , 'theme' , 'docs_directory' , 'user' , 'slug' , 'version' , 'copyright' , 'status' )
58
+
59
59
def clean_repo (self ):
60
60
repo = self .cleaned_data .get ('repo' , '' ).strip ()
61
61
if '&&' in repo or '|' in repo :
@@ -70,15 +70,15 @@ def save(self, *args, **kwargs):
70
70
71
71
# kick off the celery job
72
72
update_docs .delay (pk = project .pk )
73
-
73
+
74
74
return project
75
75
76
76
77
77
class FileForm (forms .ModelForm ):
78
78
content = forms .CharField (widget = forms .Textarea (attrs = {'class' : 'editor' }),
79
79
help_text = '<small><a href="http://sphinx.pocoo.org/rest.html">reStructuredText Primer</a></small>' )
80
80
revision_comment = forms .CharField (max_length = 255 , required = False )
81
-
81
+
82
82
class Meta :
83
83
model = File
84
84
exclude = ('project' , 'slug' , 'status' )
@@ -89,28 +89,28 @@ def __init__(self, instance=None, *args, **kwargs):
89
89
file_qs = file_qs .exclude (pk = instance .pk )
90
90
self .base_fields ['parent' ].queryset = file_qs
91
91
super (FileForm , self ).__init__ (instance = instance , * args , ** kwargs )
92
-
92
+
93
93
def save (self , * args , ** kwargs ):
94
94
# grab the old content before saving
95
95
old_content = self .initial .get ('content' , '' )
96
-
96
+
97
97
# save the file object
98
98
file_obj = super (FileForm , self ).save (* args , ** kwargs )
99
-
99
+
100
100
# create a new revision from the old content -> new
101
101
file_obj .create_revision (
102
102
old_content ,
103
103
self .cleaned_data .get ('revision_comment' , '' )
104
104
)
105
105
106
106
update_docs .delay (file_obj .project .pk )
107
-
107
+
108
108
return file_obj
109
109
110
110
111
111
class FileRevisionForm (forms .Form ):
112
112
revision = forms .ModelChoiceField (queryset = None )
113
-
113
+
114
114
def __init__ (self , file , * args , ** kwargs ):
115
115
revision_qs = file .revisions .exclude (pk = file .current_revision .pk )
116
116
self .base_fields ['revision' ].queryset = revision_qs
0 commit comments