Skip to content

Commit

Permalink
Merge pull request #3061 from artragis/fix_dates
Browse files Browse the repository at this point in the history
[15.9RC3]Corrige les bugs de mise à jour des dates
  • Loading branch information
pierre-24 committed Oct 9, 2015
2 parents 89511e0 + c735a9a commit be5dd3d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
19 changes: 10 additions & 9 deletions zds/tutorialv2/management/commands/migrate_to_zep12.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def export_comments(reacts, exported, read_class, old_last_note_pk):
for dislike in CommentDislike.objects.filter(comments__pk=note.pk).all():
dislike.comments = new_reac
dislike.save()
exported.save()
exported.save(update_date=False)


def progressbar(it, prefix="", size=60):
Expand Down Expand Up @@ -248,7 +248,8 @@ def migrate_articles():
exported.licence = current.licence
exported.js_support = current.js_support
exported.pubdate = current.pubdate
exported.save() # before updating `ManyToMany` relation, we need to save !
exported.update_date = current.update
exported.save(update_date=False) # before updating `ManyToMany` relation, we need to save !

try:
clean_commit = copy_and_clean_repo(current.get_path(False), exported.get_repo_path(False))
Expand Down Expand Up @@ -317,7 +318,7 @@ def migrate_articles():
split_article_in_extracts(versioned) # create extracts from text
exported.sha_draft = versioned.commit_changes(u'Migration version 2')
exported.old_pk = current.pk
exported.save()
exported.save(update_date=False)

reacts = Reaction.objects.filter(article__pk=current.pk)\
.select_related("author")\
Expand All @@ -343,7 +344,7 @@ def migrate_articles():
exported.update_date = current.update
exported.sha_public = exported.sha_draft
exported.public_version = published
exported.save()
exported.save(update_date=False)
published.content_public_slug = exported.slug
published.publication_date = exported.pubdate
published.save()
Expand Down Expand Up @@ -397,7 +398,7 @@ def migrate_tuto(tutos, title="Exporting mini tuto"):
exported.js_support = current.js_support
exported.source = current.source
exported.pubdate = current.pubdate
exported.save()
exported.save(update_date=False)

try:
clean_commit = copy_and_clean_repo(current.get_path(False), exported.get_repo_path(False))
Expand All @@ -418,7 +419,7 @@ def migrate_tuto(tutos, title="Exporting mini tuto"):
[exported.subcategory.add(category) for category in current.subcategory.all()]
[exported.helps.add(help) for help in current.helps.all()]
[exported.authors.add(author) for author in current.authors.all()]
exported.save()
exported.save(update_date=False)

# now, re create the manifest.json
versioned = exported.load_version()
Expand Down Expand Up @@ -449,7 +450,7 @@ def migrate_tuto(tutos, title="Exporting mini tuto"):
exported.sha_draft = versioned.commit_changes(u"Migration version 2")

exported.old_pk = current.pk
exported.save()
exported.save(update_date=False)
# export beta forum post
former_topic = Topic.objects.filter(key=current.pk).first()
if former_topic is not None:
Expand All @@ -462,7 +463,7 @@ def migrate_tuto(tutos, title="Exporting mini tuto"):
former_first_post.update_content(text)
former_first_post.save()
exported.beta_topic = former_topic
exported.save()
exported.save(update_date=False)
# extract notes
reacts = Note.objects.filter(tutorial__pk=current.pk)\
.select_related("author")\
Expand All @@ -476,7 +477,7 @@ def migrate_tuto(tutos, title="Exporting mini tuto"):
exported.pubdate = current.pubdate
exported.sha_public = current.sha_public
exported.public_version = published
exported.save()
exported.save(update_date=False)
published.content_public_slug = exported.slug
published.publication_date = current.pubdate
published.save()
Expand Down
4 changes: 3 additions & 1 deletion zds/tutorialv2/models/models_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ def save(self, *args, **kwargs):
Rewrite the `save()` function to handle slug uniqueness
"""
self.slug = uuslug(self.title, instance=self, max_length=80)
self.update_date = datetime.now()
update_date = kwargs.pop("update_date", True)
if update_date:
self.update_date = datetime.now()
super(PublishableContent, self).save(*args, **kwargs)

def get_absolute_url(self):
Expand Down
1 change: 1 addition & 0 deletions zds/tutorialv2/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ def publish_content(db_object, versioned, is_major_update=True):
# 1. markdown file (base for the others) :
# If we come from a command line, we need to activate i18n, to have the date in the french language.
cur_language = translation.get_language()
versioned.pubdate = datetime.now()
try:
translation.activate(settings.LANGUAGE_CODE)
parsed = render_to_string('tutorialv2/export/content.md', {'content': versioned})
Expand Down

0 comments on commit be5dd3d

Please sign in to comment.