Fix clone problem
This commit is contained in:
parent
65e7d4961d
commit
14ecef649e
2 changed files with 3 additions and 3 deletions
|
@ -556,10 +556,10 @@ class Problem(models.Model, PageVotable, Bookmarkable):
|
||||||
cache.set(key, result)
|
cache.set(key, result)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, should_move_data=True, *args, **kwargs):
|
||||||
code_changed = self.__original_code and self.code != self.__original_code
|
code_changed = self.__original_code and self.code != self.__original_code
|
||||||
super(Problem, self).save(*args, **kwargs)
|
super(Problem, self).save(*args, **kwargs)
|
||||||
if code_changed:
|
if code_changed and should_move_data:
|
||||||
if hasattr(self, "data_files") or self.pdf_description:
|
if hasattr(self, "data_files") or self.pdf_description:
|
||||||
try:
|
try:
|
||||||
problem_data_storage.rename(self.__original_code, self.code)
|
problem_data_storage.rename(self.__original_code, self.code)
|
||||||
|
|
|
@ -1186,7 +1186,7 @@ class ProblemClone(
|
||||||
problem.ac_rate = 0
|
problem.ac_rate = 0
|
||||||
problem.user_count = 0
|
problem.user_count = 0
|
||||||
problem.code = form.cleaned_data["code"]
|
problem.code = form.cleaned_data["code"]
|
||||||
problem.save()
|
problem.save(should_move_data=False)
|
||||||
problem.authors.add(self.request.profile)
|
problem.authors.add(self.request.profile)
|
||||||
problem.allowed_languages.set(languages)
|
problem.allowed_languages.set(languages)
|
||||||
problem.language_limits.set(language_limits)
|
problem.language_limits.set(language_limits)
|
||||||
|
|
Loading…
Reference in a new issue