Skip to content

Commit

Permalink
Lint code
Browse files Browse the repository at this point in the history
  • Loading branch information
sounak98 committed Aug 16, 2019
1 parent a43010d commit 1a70115
Show file tree
Hide file tree
Showing 81 changed files with 3,170 additions and 2,111 deletions.
2 changes: 1 addition & 1 deletion blogs_list/apps.py
Expand Up @@ -2,4 +2,4 @@


class BlogsListConfig(AppConfig):
name = 'blogs_list'
name = "blogs_list"
18 changes: 10 additions & 8 deletions blogs_list/feeds.py
Expand Up @@ -21,7 +21,7 @@ def remove_control_characters(s):

def get_request(language=None):
request_factory = RequestFactory()
request = request_factory.get('/')
request = request_factory.get("/")
request.session = {}
request.LANGUAGE_CODE = language or settings.LANGUAGE_CODE

Expand All @@ -32,15 +32,15 @@ def get_request(language=None):


class CorrectMimeTypeFeed(DefaultFeed):
content_type = 'application/xml; charset=utf-8'
content_type = "application/xml; charset=utf-8"


class BlogsFeed(Feed):
title = "GSoC@PSF Blogs"
link = '/blogs/'
feed_url = '/blogs/feed/'
link = "/blogs/"
feed_url = "/blogs/feed/"
feed_type = CorrectMimeTypeFeed
description = 'Updates on different student blogs of GSoC@PSF'
description = "Updates on different student blogs of GSoC@PSF"

def items(self):
gsoc_year = GsocYear.objects.first()
Expand Down Expand Up @@ -73,13 +73,15 @@ def item_pubdate(self, item):

def item_guid(self, item):
site = Site.objects.first()
return 'http://{}{}'.format(site.domain, self.item_link(item))
return "http://{}{}".format(site.domain, self.item_link(item))

def item_guid_is_permalink(self, item):
return True

def item_link(self, item):
section = item.app_config
p = Page.objects.get(application_namespace=section.namespace, publisher_is_draft=False)
url = '{}{}/'.format(p.get_absolute_url(), item.slug, '/')
p = Page.objects.get(
application_namespace=section.namespace, publisher_is_draft=False
)
url = "{}{}/".format(p.get_absolute_url(), item.slug, "/")
return url
4 changes: 2 additions & 2 deletions blogs_list/urls.py
Expand Up @@ -4,6 +4,6 @@
from .feeds import BlogsFeed

urlpatterns = [
url('^$', list_blogs, name='list_blogs'),
url('feed/', BlogsFeed(), name='feed')
url("^$", list_blogs, name="list_blogs"),
url("feed/", BlogsFeed(), name="feed"),
]
52 changes: 29 additions & 23 deletions blogs_list/views.py
Expand Up @@ -4,17 +4,14 @@
from django.shortcuts import render
from django.contrib import messages

from gsoc.models import (
GsocYear,
UserProfile
)
from gsoc.models import GsocYear, UserProfile
from gsoc.settings import MEDIA_URL

from cms.models import Page


def list_blogs(request):
gsoc_years = GsocYear.objects.all().order_by('-gsoc_year')
gsoc_years = GsocYear.objects.all().order_by("-gsoc_year")

blogsets = []
for year in gsoc_years:
Expand All @@ -26,29 +23,38 @@ def list_blogs(request):
if profile.app_config:
flag = True
ns = profile.app_config.namespace
page = Page.objects.get(application_namespace=ns, publisher_is_draft=False)
page = Page.objects.get(
application_namespace=ns, publisher_is_draft=False
)
student_name = profile.user.get_full_name()
student_username = profile.user.username
proposal_name = profile.accepted_proposal_pdf.name if profile.proposal_confirmed else None
proposal_path = os.path.join(MEDIA_URL, proposal_name) if proposal_name else None

blogset.append({
'title': profile.app_config.app_title,
'url': page.get_absolute_url(),
'student': student_name if student_name else student_username,
'suborg': profile.suborg_full_name.suborg_name,
'color': random.choice(['umber', 'khaki', 'wine', 'straw']),
'proposal': proposal_path if proposal_name else None,
})
proposal_name = (
profile.accepted_proposal_pdf.name
if profile.proposal_confirmed
else None
)
proposal_path = (
os.path.join(MEDIA_URL, proposal_name) if proposal_name else None
)

blogset.append(
{
"title": profile.app_config.app_title,
"url": page.get_absolute_url(),
"student": student_name if student_name else student_username,
"suborg": profile.suborg_full_name.suborg_name,
"color": random.choice(["umber", "khaki", "wine", "straw"]),
"proposal": proposal_path if proposal_name else None,
}
)

if flag:
blogset = sorted(blogset, key=lambda i: (i['title']))
blogset = sorted(blogset, key=lambda i: (i["title"]))
blogsets.append((year.gsoc_year, blogset))

if not blogsets:
messages.add_message(request, messages.ERROR,
'No blogs currently! Please visit again later.')
messages.add_message(
request, messages.ERROR, "No blogs currently! Please visit again later."
)

return render(request, 'list_view.html', {
'blogsets': blogsets,
})
return render(request, "list_view.html", {"blogsets": blogsets})

0 comments on commit 1a70115

Please sign in to comment.