Skip to content

Commit e822faf

Browse files
committed
community/: Add web-page displaying mentors
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 #271
1 parent 5871a9a commit e822faf

File tree

8 files changed

+211
-3
lines changed

8 files changed

+211
-3
lines changed

community/urls.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from community.views import (
1111
HomePageView, JoinCommunityView,
1212
OrganizationTeams, InactiveIssuesList,
13-
UnassignedIssuesActivityList
13+
UnassignedIssuesActivityList, OrganizationMentors
1414
)
1515
from gci.views import GCIStudentsList
1616
from gci.feeds import LatestTasksFeed as gci_tasks_rss
@@ -46,6 +46,12 @@ def get_index():
4646
distill_func=get_index,
4747
distill_file='teams/index.html',
4848
),
49+
distill_url(
50+
r'mentors/', OrganizationMentors.as_view(),
51+
name='org-mentors',
52+
distill_func=get_index,
53+
distill_file='mentors/index.html',
54+
),
4955
distill_url(
5056
r'gci/tasks/rss.xml', gci_tasks_rss(),
5157
name='gci-tasks-rss',

community/views.py

+47-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
from datetime import datetime
23

34
import logging
45

@@ -23,7 +24,7 @@
2324
NewcomerPromotion,
2425
Feedback
2526
)
26-
from data.models import Team, InactiveIssue, UnassignedIssuesActivity
27+
from data.models import Team, InactiveIssue, UnassignedIssuesActivity, Mentor
2728
from gamification.models import Participant as GamificationParticipant
2829
from meta_review.models import Participant as MetaReviewer
2930

@@ -244,3 +245,48 @@ def get_context_data(self, **kwargs):
244245
context = get_header_and_footer(context)
245246
context['page_name'] = 'Unassigned Issues Activity List'
246247
return context
248+
249+
250+
class OrganizationMentors(ListView):
251+
252+
template_name = 'mentors.html'
253+
model = Mentor
254+
today = datetime.today()
255+
context = None
256+
257+
def get_gsoc_students_details(self):
258+
gsoc_previous_year_mentors = False
259+
if self.today.month > 10: # GSoC ends in September
260+
year = self.today.year + 1
261+
mentors = Mentor.objects.filter(year=year, program='GSoC')
262+
if not mentors.exists():
263+
year = self.today.year
264+
gsoc_previous_year_mentors = True
265+
266+
else:
267+
year = self.today.year
268+
section_name = f"Google Summer of Code'{year} Mentors"
269+
mentors = Mentor.objects.filter(year=year, program='GSoC')
270+
self.context['gsoc_previous_mentors'] = gsoc_previous_year_mentors
271+
self.context['gsoc_section_name'] = section_name
272+
self.context['gsoc_mentors'] = mentors
273+
274+
def get_gci_students_details(self):
275+
gci_previous_year_mentors = False
276+
year = self.today.year
277+
mentors = Mentor.objects.filter(year=year, program='GCI')
278+
if not mentors.exists():
279+
year = self.today.year-1
280+
mentors = Mentor.objects.filter(year=year, program='GCI')
281+
gci_previous_year_mentors = True
282+
section_name = f"Google Code-In'{year} Mentors"
283+
self.context['gci_previous_mentors'] = gci_previous_year_mentors
284+
self.context['gci_section_name'] = section_name
285+
self.context['gci_mentors'] = mentors
286+
287+
def get_context_data(self, **kwargs):
288+
context = super().get_context_data(**kwargs)
289+
self.context = get_header_and_footer(context)
290+
self.get_gsoc_students_details()
291+
self.get_gci_students_details()
292+
return self.context

data/migrations/0011_mentor.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 2.1.7 on 2019-08-02 14:29
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('data', '0010_unassignedissuesactivity'),
10+
]
11+
12+
operations = [
13+
migrations.CreateModel(
14+
name='Mentor',
15+
fields=[
16+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
17+
('username', models.CharField(max_length=100)),
18+
('name', models.CharField(max_length=100)),
19+
('year', models.SmallIntegerField(verbose_name='Mentoring year')),
20+
('program', models.CharField(max_length=20, verbose_name='Mentoring program')),
21+
],
22+
),
23+
]

data/models.py

+7
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,10 @@ class UnassignedIssuesActivity(models.Model):
132132
repository = models.CharField(max_length=100)
133133
number = models.SmallIntegerField()
134134
url = models.URLField()
135+
136+
137+
class Mentor(models.Model):
138+
username = models.CharField(max_length=100)
139+
name = models.CharField(max_length=100)
140+
year = models.SmallIntegerField(verbose_name='Mentoring year')
141+
program = models.CharField(max_length=20, verbose_name='Mentoring program')

static/css/mentors.css

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.mentors-list {
2+
width: 100%;
3+
}
4+
5+
.program-input-field {
6+
width: 200px;
7+
float: right;
8+
margin-right: 20px;
9+
}
10+
11+
.program-input-field label {
12+
font-size: 1.3em;
13+
}

static/js/mentors.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
$(document).ready(function () {
2+
var program_selector = $('select#program');
3+
program_selector.on('change', function () {
4+
var page_name = program_selector.val();
5+
$('.page-name').text(page_name);
6+
if(page_name.search('Summer') > 0){
7+
$('.gsoc-mentors').css('display', 'flex');
8+
$('.gci-mentors').css('display', 'none');
9+
}
10+
else if(page_name.search('Code-In') > 0){
11+
$('.gsoc-mentors').css('display', 'none');
12+
$('.gci-mentors').css('display', 'flex');
13+
}
14+
});
15+
});

templates/base.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
<ul id="organisation-dropdown" class="dropdown-content">
7777
<li class="teams-dropdown-option display-none"><a href="{% url 'org-teams' %}" class="">Teams</a></li>
7878
<li><a href="{% url 'community-data' %}">Contributors Information</a></li>
79-
<li><a href="#">Mentors</a></li>
79+
<li><a href="{% url 'org-mentors' %}">Mentors</a></li>
8080
<li><a href="{% url 'community-gci' %}">Google Code-in Students</a></li>
8181
<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>
8282
<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>

templates/mentors.html

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{% extends 'base.html' %}
2+
{% load staticfiles %}
3+
4+
{% block add_css_files %}
5+
<link rel="stylesheet" href="{% static 'css/contributors.css' %}">
6+
<link rel="stylesheet" href="{% static 'css/mentors.css' %}">
7+
{% endblock %}
8+
9+
{% block add_js_files %}
10+
<script src="{% static 'js/mentors.js' %}"></script>
11+
{% endblock %}
12+
13+
{% block main-content %}
14+
15+
<div class="web-page-details apply-flex center-content">
16+
<h3 style="padding-right: 15px">~</h3>
17+
<h3 class="page-name">
18+
{{ gsoc_section_name }}
19+
</h3>
20+
<h3 style="padding-left: 15px">~</h3>
21+
</div>
22+
23+
<div class="apply-flex-center">
24+
<p class="container web-page-description">
25+
Thank You! Mentors for mentoring the potential contributors to get
26+
there work completed on time by helping them out in their project &
27+
reviewing their works too. <i class="fa fa-smile-o"></i>
28+
</p>
29+
</div>
30+
31+
<div class="organization-mentors">
32+
<div class="program-input-field">
33+
<label for="program">Program-</label>
34+
<select id="program">
35+
<option value="{{ gsoc_section_name }}">Google Summer of Code</option>
36+
<option value="{{ gci_section_name }}">Google Code-In</option>
37+
</select>
38+
</div>
39+
<div class="gsoc-mentors mentors-list apply-flex center-content">
40+
{% for mentor in gsoc_mentors %}
41+
<div class="contributor-card">
42+
<div class="contributor-image">
43+
<img src="//github.com/{{ mentor.username }}.png/?size=210"
44+
alt="mentor-image">
45+
</div>
46+
<div class="contributor-details">
47+
<a class="bold-text large-font" href="//github.com/{{ mentor.username }}" target="_blank">
48+
{% if contributor.name %}
49+
{{ mentor.name }}
50+
{% else %}
51+
{{ mentor.username }}
52+
{% endif %}
53+
</a>
54+
</div>
55+
</div>
56+
{% empty %}
57+
<h6 class="bold-text custom-green-color-font">
58+
Note: They are currently no mentor records in our database.
59+
</h6>
60+
{% endfor %}
61+
{% if gsoc_previous_mentors %}
62+
<h6 class="bold-text custom-green-color-font">
63+
Note: They are currently no mentors for upcoming Google Summer of
64+
Code.
65+
</h6>
66+
{% endif %}
67+
</div>
68+
<div class="gci-mentors mentors-list apply-flex center-content display-none">
69+
{% for mentor in gci_mentors %}
70+
<div class="contributor-card">
71+
<div class="contributor-image">
72+
<img src="//github.com/{{ mentor.username }}.png/?size=210"
73+
alt="mentor-image">
74+
</div>
75+
<div class="contributor-details">
76+
<a class="bold-text large-font" href="//github.com/{{ mentor.username }}" target="_blank">
77+
{% if contributor.name %}
78+
{{ mentor.name }}
79+
{% else %}
80+
{{ mentor.username }}
81+
{% endif %}
82+
</a>
83+
</div>
84+
</div>
85+
{% empty %}
86+
<h6 class="bold-text custom-green-color-font">
87+
Note: They are currently no mentor records in our database.
88+
</h6>
89+
{% endfor %}
90+
{% if gsoc_previous_mentors %}
91+
<h6 class="bold-text custom-green-color-font">
92+
Note: They are currently no mentors for upcoming Google Code-In.
93+
</h6>
94+
{% endif %}
95+
</div>
96+
</div>
97+
98+
{% endblock %}

0 commit comments

Comments
 (0)