File tree 2 files changed +20
-0
lines changed 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ class Meta:
30
30
states_fields = ["active" , "hidden" ]
31
31
privacy_fields = ["privacy_level" ]
32
32
fields = (
33
+ "slug" ,
33
34
* states_fields ,
34
35
* privacy_fields ,
35
36
)
@@ -88,8 +89,22 @@ def _is_default_version(self):
88
89
project = self .instance .project
89
90
return project .default_version == self .instance .slug
90
91
92
+ def clean_slug (self ):
93
+ slug = self .cleaned_data ["slug" ]
94
+ if "slug" in self .changed_data and self .instance .machine :
95
+ raise forms .ValidationError (
96
+ _ ("The slug cannot be changed." ),
97
+ )
98
+ # TODO: check for unique slug instead of having django 500.
99
+ return slug
100
+
91
101
def save (self , commit = True ):
92
102
obj = super ().save (commit = commit )
103
+
104
+ if "slug" in self .changed_data and self ._was_active and self .instance .active :
105
+ obj .recreate ()
106
+ return obj
107
+
93
108
obj .post_save (was_active = self ._was_active )
94
109
return obj
95
110
Original file line number Diff line number Diff line change @@ -440,6 +440,11 @@ def post_save(self, was_active=False):
440
440
trigger_build (project = self .project , version = self )
441
441
# Purge the cache from the CDN.
442
442
version_changed .send (sender = self .__class__ , version = self )
443
+
444
+ def recreate (self ):
445
+ self .clean_resources ()
446
+ trigger_build (project = self .project , version = self )
447
+ version_changed .send (sender = self .__class__ , version = self )
443
448
444
449
@property
445
450
def identifier_friendly (self ):
You can’t perform that action at this time.
0 commit comments