4
4
from __future__ import (
5
5
absolute_import , division , print_function , unicode_literals )
6
6
7
- from builtins import object
8
7
from random import choice
9
8
9
+ from builtins import object
10
10
from django import forms
11
11
from django .conf import settings
12
12
from django .contrib .auth .models import User
19
19
20
20
from readthedocs .builds .constants import TAG
21
21
from readthedocs .core .utils import slugify , trigger_build
22
+ from readthedocs .core .utils .extend import SettingsOverrideObject
22
23
from readthedocs .integrations .models import Integration
23
24
from readthedocs .oauth .models import RemoteRepository
24
25
from readthedocs .projects import constants
@@ -230,7 +231,7 @@ class Meta(object):
230
231
)
231
232
232
233
233
- class ProjectRelationshipForm (forms .ModelForm ):
234
+ class ProjectRelationshipBaseForm (forms .ModelForm ):
234
235
235
236
"""Form to add/update project relationships."""
236
237
@@ -243,7 +244,7 @@ class Meta(object):
243
244
def __init__ (self , * args , ** kwargs ):
244
245
self .project = kwargs .pop ('project' )
245
246
self .user = kwargs .pop ('user' )
246
- super (ProjectRelationshipForm , self ).__init__ (* args , ** kwargs )
247
+ super (ProjectRelationshipBaseForm , self ).__init__ (* args , ** kwargs )
247
248
# Don't display the update form with an editable child, as it will be
248
249
# filtered out from the queryset anyways.
249
250
if hasattr (self , 'instance' ) and self .instance .pk is not None :
@@ -281,6 +282,10 @@ def get_subproject_queryset(self):
281
282
return queryset
282
283
283
284
285
+ class ProjectRelationshipForm (SettingsOverrideObject ):
286
+ _default_class = ProjectRelationshipBaseForm
287
+
288
+
284
289
class DualCheckboxWidget (forms .CheckboxInput ):
285
290
286
291
"""Checkbox with link to the version's built documentation."""
@@ -481,7 +486,7 @@ def save(self):
481
486
return self .project
482
487
483
488
484
- class TranslationForm (forms .Form ):
489
+ class TranslationBaseForm (forms .Form ):
485
490
486
491
"""Project translation form."""
487
492
@@ -490,7 +495,7 @@ class TranslationForm(forms.Form):
490
495
def __init__ (self , * args , ** kwargs ):
491
496
self .parent = kwargs .pop ('parent' , None )
492
497
self .user = kwargs .pop ('user' )
493
- super (TranslationForm , self ).__init__ (* args , ** kwargs )
498
+ super (TranslationBaseForm , self ).__init__ (* args , ** kwargs )
494
499
self .fields ['project' ].choices = self .get_choices ()
495
500
496
501
def get_choices (self ):
@@ -563,6 +568,10 @@ def save(self):
563
568
return project
564
569
565
570
571
+ class TranslationForm (SettingsOverrideObject ):
572
+ _default_class = TranslationBaseForm
573
+
574
+
566
575
class RedirectForm (forms .ModelForm ):
567
576
568
577
"""Form for project redirects."""
0 commit comments