Skip to content

Commit

Permalink
views.py pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
AliYmn committed Feb 12, 2017
1 parent 45e4762 commit 5fdd21f
Showing 1 changed file with 29 additions and 18 deletions.
47 changes: 29 additions & 18 deletions blog/views.py
Expand Up @@ -2,7 +2,7 @@
from .models import Post,Category,Love,Skills,IpController,Tags
from django.shortcuts import get_list_or_404
class HomeListView(ListView):

"""Ana Sayfa"""
model = Post
queryset = Post.objects.all().filter(is_active=True).order_by('?')
context_object_name = 'post_obj'
Expand All @@ -15,6 +15,7 @@ def get_context_data(self, **kwargs):
return context

class PostDetailView(DetailView):
"""Post detay sayfası"""
model = Post
template_name = 'post.html'
context_object_name = 'post_obj'
Expand All @@ -30,11 +31,15 @@ def get_context_data(self, **kwargs):
context['category'] = Category.objects.all()
context['post'] = Post.objects.all().filter(is_active=True).order_by('-site_hit')[:5]

ip = IpController.objects.all().filter(remote=str(self.request.META.get('REMOTE_ADDR')),http_x=str(self.request.META.get('HTTP_X_FORWARDED_FOR')),
http_user=str(self.request.META['HTTP_USER_AGENT']),url=str(self.kwargs['slug']))
ip = IpController.objects.all().filter(remote=str(self.request.META.get('REMOTE_ADDR')),
http_x=str(self.request.META.get('HTTP_X_FORWARDED_FOR')),
http_user=str(self.request.META['HTTP_USER_AGENT']),
url=str(self.kwargs['slug']))
if(not ip):
IpController.objects.create(remote=str(self.request.META.get('REMOTE_ADDR')),http_x=str(self.request.META.get('HTTP_X_FORWARDED_FOR')),
http_user=str(self.request.META['HTTP_USER_AGENT']),url=str(self.kwargs['slug'])).save()
IpController.objects.create(remote=str(self.request.META.get('REMOTE_ADDR')),
http_x=str(self.request.META.get('HTTP_X_FORWARDED_FOR')),
http_user=str(self.request.META['HTTP_USER_AGENT']),
url=str(self.kwargs['slug'])).save()

hit = Post.objects.get(url=self.kwargs['slug'])
hit.site_hit += 1
Expand All @@ -43,6 +48,7 @@ def get_context_data(self, **kwargs):
return context

class AboutTemplateView(TemplateView):
"""Hakkımızda"""
template_name = 'about.html'

def get_context_data(self, **kwargs):
Expand All @@ -53,6 +59,7 @@ def get_context_data(self, **kwargs):
return context

class BlogListView(ListView):
"""Blog Listeleme"""
model = Post
queryset = Post.objects.all().filter(is_active=True).order_by('-time')
context_object_name = 'post_obj'
Expand All @@ -69,6 +76,7 @@ def get_context_data(self, **kwargs):
return context

class ContactView(TemplateView):
"""İletişim"""
template_name = 'contact.html'

def get_context_data(self, **kwargs):
Expand All @@ -77,26 +85,29 @@ def get_context_data(self, **kwargs):
return context

class CategoryView(ListView):
model = Post
template_name = 'category_page.html'
context_object_name = 'post_obj'
paginate_by = 3
def get_queryset(self, *args, **kwargs):
return get_list_or_404(Post.objects.filter(category_list__url=self.kwargs['slug'],is_active=True))

def get_context_data(self, **kwargs):
context = super(CategoryView, self).get_context_data(**kwargs)
context['last_content'] = Post.objects.all().filter(is_active=True).order_by('-time')
context['category'] = Category.objects.all()
context['category_post'] = Category.objects.all().filter(url=self.kwargs['slug'])
return context
"""Kategori Detay"""
model = Post
template_name = 'category_page.html'
context_object_name = 'post_obj'
paginate_by = 3
def get_queryset(self, *args, **kwargs):
return get_list_or_404(Post.objects.filter(category_list__url=self.kwargs['slug'],is_active=True))

def get_context_data(self, **kwargs):
context = super(CategoryView, self).get_context_data(**kwargs)
context['last_content'] = Post.objects.all().filter(is_active=True).order_by('-time')
context['category'] = Category.objects.all()
context['category_post'] = Category.objects.all().filter(url=self.kwargs['slug'])
return context

class RobotsView(TemplateView):
"""robots.txt"""
template_name = 'robots.html'



class TagsView(ListView):
"""etiket detay"""
model = Tags
context_object_name = 'tags_obj'
template_name = 'tags.html'
Expand Down

0 comments on commit 5fdd21f

Please sign in to comment.