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

community/: Add a webpage for Listing Issues #291

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
de15cb2
Sync Moban
KVGarg Aug 4, 2019
6e9765d
data/: Update Contributor model
KVGarg Jun 8, 2019
c6afccd
.coafile: Ignore openhub module
KVGarg Jun 10, 2019
ab5e860
tests/: Remove dependency of testusers'
Jun 25, 2019
dc36c9f
travis.yml: Install Python v3.6.3
KVGarg Jul 30, 2019
c81d98c
git.py: CI build pass
KVGarg Feb 11, 2019
7f2877a
Enhance the community website homepage
KVGarg Jun 7, 2019
8323939
ci_build/: Re-design build-logs webpage
KVGarg Jun 9, 2019
6bc955e
gci/: Redesign gci students web-page
KVGarg Jun 12, 2019
0746873
data/: Re-design the contributors webpage
KVGarg Jun 13, 2019
c2f5c96
meta-review/: Redesign the webpage
KVGarg Jun 14, 2019
686c2d3
gamification/: Redesign the webpage
KVGarg Jun 14, 2019
5158608
Add netlify-OAuth
KVGarg Jul 11, 2019
41c5e35
community/: Add a joining netlify form
KVGarg Jul 20, 2019
a012693
community/: Display contributor statistics
KVGarg Jul 28, 2019
e05a821
community/: Add a form for uploading google forms
KVGarg Jul 31, 2019
7274277
community/: Add a form for adding calendar events
KVGarg Jul 31, 2019
e94bc5c
community/: Add a form for applying as a mentor
KVGarg Jul 31, 2019
6048e0e
community/: Add a form for adding a gsoc student
KVGarg Jul 31, 2019
e9dd16a
community/: Add a request form to assign issue
KVGarg Aug 1, 2019
7714d9e
community/: Add a newcomer promotion request form
KVGarg Aug 1, 2019
bfbc9c1
community/: Add a feedback form
KVGarg Aug 1, 2019
577b609
Remove openhub and model apps
Jun 28, 2019
8daed65
openhub/: Use openhub_django pypi package
Jun 28, 2019
6fe3e7f
community/: Display org teams
KVGarg Aug 2, 2019
9922faf
community/: Add a webpage for Listing Issues
KVGarg Aug 2, 2019
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
Prev Previous commit
Next Next commit
gci/: Redesign gci students web-page
The redesigned web-page displays the data
in a better UI/UX form with some additional
information to make it more interactive and
attractive.

Closes #257
  • Loading branch information
KVGarg committed Aug 5, 2019
commit 6bc955e350a107b060b68942f9d8aa7ee119c650
4 changes: 2 additions & 2 deletions community/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.conf import settings

from community.views import HomePageView
from gci.views import index as gci_index
from gci.views import GCIStudentsList
from gci.feeds import LatestTasksFeed as gci_tasks_rss
from ci_build.view_log import BuildLogsView
from data.views import index as contributors_index
Expand Down Expand Up @@ -85,7 +85,7 @@ def get_organization():
distill_file='gci/tasks/rss.xml',
),
distill_url(
r'gci/', gci_index,
r'gci/', GCIStudentsList.as_view(),
name='community-gci',
distill_func=get_index,
distill_file='gci/index.html',
Expand Down
2 changes: 1 addition & 1 deletion gci/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
from . import views

urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^$', views.GCIStudentsList.as_view(), name='index'),
]
155 changes: 80 additions & 75 deletions gci/views.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from django.http import HttpResponse
from datetime import datetime
from calendar import timegm

import logging
import requests

from django.views.generic import TemplateView

from community.views import get_header_and_footer
from data.models import Contributor
from .students import get_linked_students
from .gitorg import get_logo
from .task import get_tasks

STUDENT_URL = (
Expand All @@ -15,75 +17,78 @@
)


def index(request):
logger = logging.getLogger(__name__ + '.index')
try:
get_tasks()
except FileNotFoundError:
logger.info('GCI data not available')
s = ['GCI data not available']
else:
s = gci_overview()

return HttpResponse('\n'.join(s))


def gci_overview():
logger = logging.getLogger(__name__ + '.gci_overview')
linked_students = list(get_linked_students())
if not linked_students:
logger.info('No GCI students are linked')
return ['No GCI students are linked']

org_id = linked_students[0]['organization_id']
org_name = linked_students[0]['organization_name']
s = []
s.append('<link rel="stylesheet" href="static/main.css">')

favicon = get_logo(org_name, 16)
with open('_site/favicon.png', 'wb') as favicon_file:
favicon_file.write(favicon)

org_logo = get_logo(org_name)
with open('_site/org_logo.png', 'wb') as org_logo_file:
org_logo_file.write(org_logo)

s.append('<link rel="shortcut icon" type="image/png" '
'href="static/favicon.png"/>')
s.append('<img src="static/org_logo.png" alt="'+org_name+'">')
s.append('<h2>Welcome</h2>')
s.append('Hello, world. You are at the {org_name} community GCI website.'
.format(org_name=org_name))
s.append('Students linked to %s issues:<ul class="students">' % org_name)
for student in linked_students:
student_id = student['id']
username = student['username']

r = requests.get('https://api.github.com/users/{}'.format(username))

if r.status_code == 404:
continue

student_url = STUDENT_URL.format(org_id=org_id,
student_id=student_id,
)
s.append('<li class="student">'
'STUDENT ID: <a href="{student_url}">{student_id}</a><br />'
'<div class="github-card" data-github="{username}" '
'data-width="400" data-theme="default"></div>'
.format(student_url=student_url, student_id=student_id,
username=username))

timestamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
s.append('</ul><i id="time" class="timestamp" data-time="{unix}">'
'Last updated: {timestamp} '
'(<span id="ago" class="timeago"></span>)</i>'
.format(unix=timegm(datetime.utcnow().utctimetuple()),
timestamp=timestamp))

s.append('<script src="//cdn.jsdelivr.net/gh/lepture/[email protected]'
'/jsdelivr/widget.js"></script>')
s.append('<script src="static/timeago.js"></script>')
s.append('<script>loadTimeElements()</script>')

return s
class GCIStudentsList(TemplateView):
template_name = 'gci_students.html'

def get_data_updated_time(self):
return timegm(datetime.utcnow().utctimetuple())

def get_all_students(self):
"""
Get all GCI students by filtering the tasks that are valid
:return: A List of all students dict having necessary information
about the student
"""
logger = logging.getLogger(__name__ + '.gci_overview')
linked_students = list(get_linked_students())
data = {
'students': list(),
'error': None
}
if not linked_students:
error_message = 'No GCI students are linked'
logger.info(error_message)
data['error'] = error_message
return data
org_id = linked_students[0]['organization_id']
for student in linked_students:
student_id = student['id']
username = student['username']
contributors = Contributor.objects.filter(login=username)
if contributors:
contrib = contributors.first()
student['url'] = STUDENT_URL.format(org_id=org_id,
student_id=student_id)
student['name'] = contrib.name
student['bio'] = contrib.bio
student['public_repos'] = contrib.public_repos
student['public_gists'] = contrib.public_gists
student['followers'] = contrib.followers
data['students'].append(student)
else:
logger.warning(f"GCI Student {username} doesn't exists!"
f' Please check the username.')
return data

def get_gci_tasks_and_students(self):
"""
Get all GCI students by fetching the GCI tasks and the students
:return: A list of all GCI Students
"""
logger = logging.getLogger(__name__ + '.index')
gci_students = {
'data': {},
'error': None
}
try:
get_tasks()
except FileNotFoundError:
logger.info('GCI data not available')
error_message = ('No GCI data is available. Please create a'
' tasks.yaml file having GCI tasks related'
' data in it.')
gci_students['error'] = error_message
else:
data = self.get_all_students()
if data['error']:
gci_students['error'] = data['error']
else:
gci_students['data'] = data['students']
return gci_students

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context = get_header_and_footer(context)
context['gci_students'] = self.get_gci_tasks_and_students()
context['updated_time'] = self.get_data_updated_time()
return context
52 changes: 52 additions & 0 deletions static/css/gci_students.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
.data-fetch-error {
padding: 20px 20px 0 20px;
}

.gci-students {
padding: 2% 2%;
}

.gci-students .student-card {
box-shadow: 0 0 25px 2px black;
background-color: #c7da99;
font-size: large;
border: 4px #6c9a55 solid;
}


.gci-students .student-image {
align-items: normal;
}

.gci-students .student-details {
width: 100%;
}

@media only screen and (min-width: 768px) {
.gci-students .student-card {
width: 45%;
height: 300px;
overflow-y: auto;
}
}

.participated-year,
.gci-student-id,
.public-repos,
.public-gists,
.followers {
color: #37474f;
font-weight: bold;
padding-right: 3px;
}

.web-page-details {
width: 100%;
}

.web-page-description,
.data-updated-time,
.data-fetch-error {
text-align: center;
font-size: large;
}
31 changes: 31 additions & 0 deletions static/js/timeago.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
$(document).ready(function(){
function generateTimeString(timestamp) {
var sec = ((new Date()).getTime() / 1000) - parseInt(timestamp);
var min = sec / 60;
var hour = min / 60;
var day = hour / 24;

var timeString = '';
if (day >= 1) {
timeString = Math.round(day) + ' days ago';
} else if (hour >= 1) {
timeString = Math.round(hour) + ' hours ago';
} else if (min >= 1) {
timeString = Math.round(min) + ' minutes ago';
} else {
timeString = Math.round(sec) + ' seconds ago';
}

return timeString;
}

function updateTimeAgo(time) {
time.text(" " + generateTimeString(time.attr('data-time')));
}

function loadTimeElements() {
updateTimeAgo($('#time'));
}

loadTimeElements();
});
30 changes: 0 additions & 30 deletions static/timeago.js

This file was deleted.

1 change: 0 additions & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
<li><a href="{% url 'community-gci' %}">Google Code-in Students</a></li>
<li><a href="{% url 'inactive_issues_json' %}" title="List of all the issues on organization's main repository on which assignee has not shown any activity for more than 2 months.">Inactive issues</a></li>
<li><a href="{% url 'unassigned_issues_activity_json' %}" title="List of all the issues on organization main repository on which someone has opened a pull request without getting assigned to it.">Unassigned issues activity</a></li>
<li><a href="#">Newcomer issues</a></li>
<li><a href="{% url 'ci_build' %}">Project CI Build</a></li>
{% if isTravis %}
<li><a href="{{ travisLink }}" title="This website was built automatically using Travis CI.">TravisCI build info</a></li>
Expand Down
Loading