Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Student_Council_Website/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
'website',
'smriti',
'django_markdown',
'django_rq'
'django_rq',

)

Expand Down
6 changes: 5 additions & 1 deletion src/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@
</ul>
<ul id="dropdown4" class="dropdown-content center-align">
<li><a href="/nitk_life">NITK Life</a></li>
<li><a href="/blog">Literary Archive</a></li>
<li><a href="/blog">Blog Archive</a></li>
<li><a href="/blog/travel">Travel</a></li>
<li><a href="/blog/fineprint">Fine Print</a></li>
<li><a href="/blog/literarypage">Literary page</a></li>
<li><a href="/blog/techpost">Tech Post</a></li>
<li><a href="/resources">Resources</a></li>
<li><a href="/faq">FAQs</a></li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion src/templates/blog.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="row">
<div class="col s12">
<a href="/" class="breadcrumb">Home</a>
<a href="#!" class="breadcrumb">Literary Archive</a>
<a href="#!" class="breadcrumb">{{blogtype}} Archive</a>
</div>
</div>
</div>
Expand Down
6 changes: 5 additions & 1 deletion src/templates/static.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@
</ul>
<ul id="dropdown4" class="dropdown-content center-align">
<li><a href="/nitk_life">NITK Life</a></li>
<li><a href="/blog">Literary Archive</a></li>
<li><a href="/blog">Blog Archive</a></li>
<li><a href="/blog/travel">Travel</a></li>
<li><a href="/blog/fineprint">Fine Print</a></li>
<li><a href="/blog/literarypage">Literary page</a></li>
<li><a href="/blog/techpost">Tech Post</a></li>
<li><a href="/resources">Resources</a></li>
<li><a href="/faq">FAQs</a></li>
</ul>
Expand Down
19 changes: 10 additions & 9 deletions src/website/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,19 @@ class Author(models.Model):
blurb = MarkdownField()

def __str__(self):
return self.name
return self.name
Copy link
Contributor

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok


@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')]
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

TYPE_OF_BLOG = [
    (1, 'travel'),
    (2, 'fineprint'),
    (3, 'literarypage'),
    (4, 'techpost')
]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

page=models.IntegerField(default=0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: page = mo...

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: , null = True, blank = True

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):
Expand Down
9 changes: 6 additions & 3 deletions src/website/urls.py
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 = [
Expand All @@ -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'),
Copy link
Contributor

Choose a reason for hiding this comment

The 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'),
Copy link
Contributor

Choose a reason for hiding this comment

The 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'),
Expand Down
30 changes: 22 additions & 8 deletions src/website/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: spacing - request, p

blogtype = pagename
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the default page showing all blogs.

if pagename=="travel":
Copy link
Contributor

Choose a reason for hiding this comment

The 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):
Copy link
Contributor

Choose a reason for hiding this comment

The 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})
Copy link
Contributor

Choose a reason for hiding this comment

The 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)
Expand Down