Skip to content

Commit

Permalink
community/: Add web-page displaying mentors
Browse files Browse the repository at this point in the history
The web-page displays all the mentors
of the upcoming summer/winter program
or of previous year, if no mentors are
being found for upcoming program

Closes coala#271
  • Loading branch information
KVGarg committed Aug 6, 2019
1 parent a4ecedd commit b6d579a
Show file tree
Hide file tree
Showing 8 changed files with 210 additions and 3 deletions.
8 changes: 7 additions & 1 deletion community/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from community.views import (
HomePageView, JoinCommunityView,
OrganizationTeams, InactiveIssuesList,
UnassignedIssuesActivityList
UnassignedIssuesActivityList, OrganizationMentors
)
from gci.views import GCIStudentsList
from gci.feeds import LatestTasksFeed as gci_tasks_rss
Expand Down Expand Up @@ -45,6 +45,12 @@ def get_index():
distill_func=get_index,
distill_file='teams/index.html',
),
distill_url(
r'mentors/', OrganizationMentors.as_view(),
name='org-mentors',
distill_func=get_index,
distill_file='mentors/index.html',
),
distill_url(
r'gci/tasks/rss.xml', gci_tasks_rss(),
name='gci-tasks-rss',
Expand Down
48 changes: 47 additions & 1 deletion community/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from datetime import datetime

import logging

Expand All @@ -23,7 +24,7 @@
NewcomerPromotion,
Feedback
)
from data.models import Team, InactiveIssue, UnassignedIssuesActivity
from data.models import Team, InactiveIssue, UnassignedIssuesActivity, Mentor
from gamification.models import Participant as GamificationParticipant
from meta_review.models import Participant as MetaReviewer

Expand Down Expand Up @@ -247,3 +248,48 @@ def get_context_data(self, **kwargs):
context = get_header_and_footer(context)
context['page_name'] = 'Unassigned Issues Activity List'
return context


class OrganizationMentors(ListView):

template_name = 'mentors.html'
model = Mentor
today = datetime.today()
context = None

def get_gsoc_students_details(self):
gsoc_previous_year_mentors = False
if self.today.month > 10: # GSoC ends in September
year = self.today.year + 1
mentors = Mentor.objects.filter(year=year, program='GSoC')
if not mentors.exists():
year = self.today.year
gsoc_previous_year_mentors = True

else:
year = self.today.year
section_name = f"Google Summer of Code'{year} Mentors"
mentors = Mentor.objects.filter(year=year, program='GSoC')
self.context['gsoc_previous_mentors'] = gsoc_previous_year_mentors
self.context['gsoc_section_name'] = section_name
self.context['gsoc_mentors'] = mentors

def get_gci_students_details(self):
gci_previous_year_mentors = False
year = self.today.year
mentors = Mentor.objects.filter(year=year, program='GCI')
if not mentors.exists():
year = self.today.year-1
mentors = Mentor.objects.filter(year=year, program='GCI')
gci_previous_year_mentors = True
section_name = f"Google Code-In'{year} Mentors"
self.context['gci_previous_mentors'] = gci_previous_year_mentors
self.context['gci_section_name'] = section_name
self.context['gci_mentors'] = mentors

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
self.context = get_header_and_footer(context)
self.get_gsoc_students_details()
self.get_gci_students_details()
return self.context
23 changes: 23 additions & 0 deletions data/migrations/0011_mentor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 2.1.7 on 2019-08-02 14:29

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('data', '0010_unassignedissuesactivity'),
]

operations = [
migrations.CreateModel(
name='Mentor',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('username', models.CharField(max_length=100)),
('name', models.CharField(max_length=100)),
('year', models.SmallIntegerField(verbose_name='Mentoring year')),
('program', models.CharField(max_length=20, verbose_name='Mentoring program')),
],
),
]
7 changes: 7 additions & 0 deletions data/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,10 @@ class UnassignedIssuesActivity(models.Model):
repository = models.CharField(max_length=100)
number = models.SmallIntegerField()
url = models.URLField()


class Mentor(models.Model):
username = models.CharField(max_length=100)
name = models.CharField(max_length=100)
year = models.SmallIntegerField(verbose_name='Mentoring year')
program = models.CharField(max_length=20, verbose_name='Mentoring program')
13 changes: 13 additions & 0 deletions static/css/mentors.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.mentors-list {
width: 100%;
}

.program-input-field {
width: 200px;
float: right;
margin-right: 20px;
}

.program-input-field label {
font-size: 1.3em;
}
15 changes: 15 additions & 0 deletions static/js/mentors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
$(document).ready(function () {
var program_selector = $('select#program');
program_selector.on('change', function () {
var page_name = program_selector.val();
$('.page-name').text(page_name);
if(page_name.search('Summer') > 0){
$('.gsoc-mentors').css('display', 'flex');
$('.gci-mentors').css('display', 'none');
}
else if(page_name.search('Code-In') > 0){
$('.gsoc-mentors').css('display', 'none');
$('.gci-mentors').css('display', 'flex');
}
});
});
2 changes: 1 addition & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<ul id="organisation-dropdown" class="dropdown-content">
<li class="teams-dropdown-option display-none"><a href="{% url 'org-teams' %}" class="">Teams</a></li>
<li><a href="{% url 'community-data' %}">Contributors Information</a></li>
<li><a href="#">Mentors</a></li>
<li><a href="{% url 'org-mentors' %}">Mentors</a></li>
<li><a href="{% url 'community-gci' %}">Google Code-in Students</a></li>
<li><a href="{% url 'inactive-issues' %}" 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' %}" 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>
Expand Down
97 changes: 97 additions & 0 deletions templates/mentors.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{% extends 'base.html' %}
{% load staticfiles %}

{% block add_css_files %}
<link rel="stylesheet" href="{% static 'css/contributors.css' %}">
<link rel="stylesheet" href="{% static 'css/mentors.css' %}">
{% endblock %}

{% block add_js_files %}
<script src="{% static 'js/mentors.js' %}"></script>
{% endblock %}

{% block main-content %}

<div class="web-page-details apply-flex center-content">
<h3 style="padding-right: 15px">~</h3>
<h3 class="page-name">
{{ gsoc_section_name }}
</h3>
<h3 style="padding-left: 15px">~</h3>
</div>

<div class="apply-flex-center">
<p class="container web-page-description">
Thank You! Mentors for mentoring the potential contributors to get
there work completed on time by helping them out in their project &
reviewing their works too. <i class="fa fa-smile-o"></i>
</p>
</div>

<div class="organization-mentors">
<div class="program-input-field">
<label for="program">Program-</label>
<select id="program">
<option value="{{ gsoc_section_name }}">Google Summer of Code</option>
<option value="{{ gci_section_name }}">Google Code-In</option>
</select>
</div>
<div class="gsoc-mentors mentors-list apply-flex center-content">
{% for mentor in gsoc_mentors %}
<div class="contributor-card">
<div class="contributor-image">
<img src="//github.com/{{ mentor.username }}.png/?size=210"
alt="mentor-image">
</div>
<div class="contributor-details">
<a class="bold-text large-font" href="//github.com/{{ mentor.username }}" target="_blank">
{% if contributor.name %}
{{ mentor.name }}
{% else %}
{{ mentor.username }}
{% endif %}
</a>
</div>
</div>
{% empty %}
<h6 class="bold-text custom-green-color-font">
Note: They are currently no mentor records in our database.
</h6>
{% endfor %}
{% if gsoc_previous_mentors %}
<h6 class="bold-text custom-green-color-font">
Note: They are currently no mentors for upcoming Google Summer of
Code.
</h6>
{% endif %}
</div>
<div class="gci-mentors mentors-list apply-flex center-content display-none">
{% for mentor in gci_mentors %}
<div class="contributor-card">
<div class="contributor-image">
<img src="//github.com/{{ mentor.username }}.png/?size=210"
alt="mentor-image">
</div>
<div class="contributor-details">
<a class="bold-text large-font" href="//github.com/{{ mentor.username }}" target="_blank">
{% if contributor.name %}
{{ mentor.name }}
{% else %}
{{ mentor.username }}
{% endif %}
</a>
</div>
</div>
{% empty %}
<h6 class="bold-text custom-green-color-font">
Note: They are currently no mentor records in our database.
</h6>
{% endfor %}
{% if gsoc_previous_mentors %}
<h6 class="bold-text custom-green-color-font">
Note: They are currently no mentors for upcoming Google Code-In.
</h6>
{% endif %}
</div>
</div>
{% endblock %}

0 comments on commit b6d579a

Please sign in to comment.