Article bug fixes

remotes/origin/1203
Ivan Kovalkovskyi 10 years ago
parent 639a3edd84
commit e0e95e2db1
  1. 9
      article/admin.py
  2. 2
      article/forms.py
  3. 2
      templates/client/article/news_list.html
  4. 4
      templates/client/includes/article_theme.html
  5. 1
      theme/urls.py
  6. 16
      theme/views.py

@ -171,7 +171,10 @@ class BlogView(FormView):
article = self.obj
data = {}
data['slug'] = article.slug
data['theme'] = [item.id for item in article.blog_theme.all()]
if self.obj.type == Article.blog:
data['theme'] = [item.id for item in article.blog_theme.all()]
else:
data['theme'] = [item.id for item in article.theme.all()]
if article.exposition:
data['exposition'] = article.exposition.id
if article.conference:
@ -200,13 +203,10 @@ class BlogView(FormView):
else:
return form_class()
def get_context_data(self, **kwargs):
context = super(BlogView, self).get_context_data(**kwargs)
self.set_obj()
context['article'] = self.obj
if context['article']:
context['file_form'] = FileForm(initial={'model': 'article.Article'})
@ -229,6 +229,7 @@ class NewsList(ListView):
context['news_flag'] = True
return context
class NewsView(BlogView):
form_class = NewsForm
template_name = 'article/blog_form.html'

@ -108,8 +108,10 @@ class NewsForm(BlogForm):
article = super(NewsForm, self).save(author, article)
exposition = self.cleaned_data.get('exposition')
conference = self.cleaned_data.get('conference')
theme = self.cleaned_data.get('theme')
article.exposition = exposition
article.conference = conference
article.theme = theme
article.save()
return article

@ -48,7 +48,7 @@
},
tags:{
placeholder:"{% trans 'Выберите ключевые теги' %}",
url:'http://{{ request.get_host }}/theme/get-tag/'
url:'http://{{ request.get_host }}/theme/get-news-tag/'
}
});
</script>

@ -1,6 +1,6 @@
{% with theme=obj.theme.all %}
{% for theme in obj.theme.all %}
{% with theme=obj.blog_theme.all %}
{% for theme in obj.blog_theme.all %}
<a href="{{ obj.get_catalog }}theme/{{ theme.url }}/" title="">{{ theme.name }}</a>{% if forloop.counter != themes|length %},{% endif %}
{% endfor %}
{% endwith %}

@ -4,4 +4,5 @@ from django.conf.urls import patterns, url
urlpatterns = patterns('',
url(r'^get-tag/$', 'theme.views.get_tag'),
url(r'^get-article-tags/$', 'theme.views.get_article_tags'),
url(r'^get-news-tag/$', 'theme.views.get_news_tags'),
)

@ -7,7 +7,7 @@ def get_tag(request):
#if request.is_ajax():
themes = request.GET.getlist('themes[]')
term = request.GET['term'].capitalize()
qs = Tag.objects.language().exclude(theme__article__id=None).distinct()
qs = Tag.objects.language().distinct()
if term:
qs = qs.filter(translations__name__contains=term)
if themes:
@ -28,4 +28,18 @@ def get_article_tags(request):
result = [{'id': tag.id, 'label': '%s (%s)'%(tag.name, tag.theme.name)} for tag in qs]
result = sorted(result, key=lambda x:x['label'])
return HttpResponse(json.dumps(result), content_type='application/json')
def get_news_tags(request):
themes = request.GET.getlist('themes[]')
term = request.GET['term'].capitalize()
qs = Tag.objects.language().exclude(article=None).filter(article__type=2).distinct()
if term:
qs = qs.filter(translations__name__contains=term)
if themes:
qs = qs.filter(theme__id__in=themes).order_by('translations__name')
result = [{'id': tag.id, 'label': '%s (%s)'%(tag.name, tag.theme.name)} for tag in qs]
result = sorted(result, key=lambda x:x['label'])
return HttpResponse(json.dumps(result), content_type='application/json')
Loading…
Cancel
Save