-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
blog pages added #70
base: master
Are you sure you want to change the base?
blog pages added #70
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,7 +80,7 @@ | |
'website', | ||
'smriti', | ||
'django_markdown', | ||
'django_rq' | ||
'django_rq', | ||
|
||
) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,18 +123,19 @@ class Author(models.Model): | |
blurb = MarkdownField() | ||
|
||
def __str__(self): | ||
return self.name | ||
return self.name | ||
|
||
@python_2_unicode_compatible | ||
class Articles(models.Model): | ||
title = models.CharField(max_length=200) | ||
author = models.ForeignKey(Author) | ||
article_pic = models.ImageField(upload_to='article_pics/%Y-%m-%d/',null=True,blank=True) | ||
content = MarkdownField() | ||
published = models.DateTimeField(auto_now_add=True) | ||
|
||
def __str__(self): | ||
return self.title | ||
TYPE_OF_BLOG=[(1,'travel'),(2,'fineprint'),(3,'literarypage'),(4,'techpost')] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Try and put spaces between operators and space out these long lists when possible! Something like the following looks nicer and is easier to add on to in the future.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
page=models.IntegerField(default=0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
title = models.CharField(max_length=200) | ||
author = models.ForeignKey(Author) | ||
article_pic = models.ImageField(upload_to='article_pics/%Y-%m-%d/',null=True,blank=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: spaces and maybe break this into multiple lines? |
||
content = MarkdownField() | ||
published = models.DateTimeField(auto_now_add=True) | ||
def __str__(self): | ||
return self.title | ||
|
||
@python_2_unicode_compatible | ||
class Complaint(models.Model): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from django.conf.urls import url | ||
from django.conf.urls import url,include | ||
from . import views | ||
|
||
urlpatterns = [ | ||
|
@@ -10,8 +10,11 @@ | |
url(r'^announce/(?P<id>[0-9]+)/$', views.announcement, name='eachAnnouncement'), | ||
url(r'^contacts/',views.ContactNumbers.as_view(),name='contacts'), | ||
url(r'^nitk_life/', views.NitkLifePage.as_view(), name='nitk_life'), | ||
url(r'^blog/$', views.blogPage, name='blogs'), | ||
url(r'^blog/(?P<num>[0-9]+)/$', views.blogPage, name='eachBlog'), | ||
# url(r'^(P<pagename>["travel"])/$', views.blogPage, name='travel'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these comments needed? |
||
#url(r'^(P<pagename>["fine_print"])/$', views.blogPage, name='fine_print'), | ||
url(r'^blog/(?P<pagename>[a-z]*)/$', views.blogPage, name='blogs'), | ||
url(r'^blog/$',views.blogPage,name='blog'), | ||
url(r'^blog/(?P<num>[0-9]+)/$', views.blogIndex, name='eachBlog'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. spacing nits here |
||
url(r'^news/$', views.newsPage, name='news'), | ||
url(r'^news/(?P<num>[0-9]+)/$', views.newsPage, name='eachNews'), | ||
url(r'^faq/',views.FAQ.as_view(),name='faq'), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
from django.core.mail import send_mail | ||
import json | ||
from django.conf import settings | ||
from django.core.urlresolvers import reverse | ||
# Create your views here. | ||
|
||
class AboutPage(generic.TemplateView): | ||
|
@@ -48,14 +49,27 @@ def announcement(request, id): | |
announcement = get_object_or_404(Announcements, id=id) | ||
return render(request,'announce_ind.html',{'announcement':announcement}) | ||
|
||
def blogPage(request, num=0): | ||
if num: | ||
article = Articles.objects.get(id=num) | ||
return render(request,'article.html',{'article':article}) | ||
else: | ||
articles = Articles.objects.all().order_by('-published') | ||
return render(request,'blog.html',{'article':articles}) | ||
|
||
def blogPage(request,pagename="blog"): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: spacing - |
||
blogtype = pagename | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is the default page showing all blogs. |
||
if pagename=="travel": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. spacing nits |
||
article = Articles.objects.filter(page=1) | ||
return render(request,'blog.html',{'article':article , 'blogtype' : blogtype}) | ||
if pagename=="fineprint": | ||
article = Articles.objects.filter(page=2) | ||
return render(request,'blog.html',{'article':article , 'blogtype' : blogtype}) | ||
if pagename=="literarypage": | ||
article = Articles.objects.filter(page=3) | ||
return render(request,'blog.html',{'article':article , 'blogtype' : blogtype}) | ||
if pagename=="techpost": | ||
article = Articles.objects.filter(page=4) | ||
return render(request,'blog.html',{'article':article , 'blogtype' : blogtype}) | ||
if pagename=="blog": | ||
articles = Articles.objects.all().order_by('-published') | ||
return render(request,'blog.html',{'article':articles , 'blogtype' : blogtype}) | ||
|
||
def blogIndex(request,num): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. spacing nits |
||
article=Articles.objects.get(id=num) | ||
return render(request,'article.html',{'article':article}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add another line below this |
||
def newsPage(request, num=0): | ||
if num: | ||
news = News.objects.get(id=num) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Follow 4 space indents to match the rest of the file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok