Skip to content

Commit

Permalink
corrige les conflits entre les articles homonymes
Browse files Browse the repository at this point in the history
  • Loading branch information
firm1 committed Jun 17, 2014
1 parent a91b371 commit f622d94
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 4 additions & 1 deletion zds/article/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ def get_absolute_url(self):
return reverse('zds.article.views.view',
kwargs={'article_pk': self.pk,
'article_slug': slugify(self.title)})

def get_slug(self):
return str(self.pk) + "_" + self.slug

def get_absolute_url_online(self):
return reverse('zds.article.views.view_online',
Expand All @@ -118,7 +121,7 @@ def get_path(self, relative=False):
if relative:
return None
else:
return os.path.join(settings.REPO_ARTICLE_PATH, self.slug)
return os.path.join(settings.REPO_ARTICLE_PATH, self.get_slug())

def load_json(self, path=None, online=False):
if path is None:
Expand Down
7 changes: 3 additions & 4 deletions zds/article/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,7 @@ def edit(request):

new_slug = os.path.join(
settings.REPO_ARTICLE_PATH,
slugify(
data['title']))
article.get_slug())

maj_repo_article(request,
old_slug_path=old_slug,
Expand All @@ -334,7 +333,7 @@ def edit(request):

return redirect(article.get_absolute_url())
else:
form = ArticleForm({
form = ArticleForm(initial={
'title': json['title'],
'description': json['description'],
'text': article.get_text(),
Expand Down Expand Up @@ -410,7 +409,7 @@ def download(request):

article = get_object_or_404(Article, pk=request.GET['article'])

ph = os.path.join(settings.REPO_ARTICLE_PATH, article.slug)
ph = os.path.join(settings.REPO_ARTICLE_PATH, article.get_slug())
repo = Repo(ph)
repo.archive(open(ph + ".tar", 'w'))

Expand Down

0 comments on commit f622d94

Please sign in to comment.