diff --git a/community/urls.py b/community/urls.py index 4c86bd59..fa3c14d3 100644 --- a/community/urls.py +++ b/community/urls.py @@ -7,7 +7,10 @@ from django.conf.urls.static import static from django.conf import settings -from community.views import HomePageView, JoinCommunityView +from community.views import ( + HomePageView, JoinCommunityView, + OrganizationTeams +) from gci.views import GCIStudentsList from gci.feeds import LatestTasksFeed as gci_tasks_rss from twitter.view_twitter import index as twitter_index @@ -40,6 +43,12 @@ def get_index(): distill_func=get_index, distill_file='join/index.html', ), + distill_url( + r'teams/', OrganizationTeams.as_view(), + name='org-teams', + distill_func=get_index, + distill_file='teams/index.html', + ), distill_url( r'gci/tasks/rss.xml', gci_tasks_rss(), name='gci-tasks-rss', diff --git a/community/views.py b/community/views.py index 6656b615..0126a6d1 100644 --- a/community/views.py +++ b/community/views.py @@ -7,6 +7,7 @@ from trav import Travis from django.views.generic.base import TemplateView +from django.views.generic import ListView from .git import ( get_org_name, @@ -206,3 +207,14 @@ def get_context_data(self, **kwargs): 'JOIN_COMMUNITY_FORM_NAME', None ) return context + + +class OrganizationTeams(ListView): + + template_name = 'teams.html' + model = Team + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context = get_header_and_footer(context) + return context diff --git a/data/migrations/0008_auto_20190802_0745.py b/data/migrations/0008_auto_20190802_0745.py new file mode 100644 index 00000000..8d39f12a --- /dev/null +++ b/data/migrations/0008_auto_20190802_0745.py @@ -0,0 +1,28 @@ +# Generated by Django 2.1.7 on 2019-08-02 07:45 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('data', '0007_auto_20190802_2015'), + ] + + operations = [ + migrations.AddField( + model_name='team', + name='description', + field=models.TextField(default=None, max_length=500, null=True), + ), + migrations.AddField( + model_name='team', + name='increased_count', + field=models.PositiveSmallIntegerField(default=0), + ), + migrations.AddField( + model_name='team', + name='members_count', + field=models.PositiveSmallIntegerField(default=0), + ), + ] diff --git a/data/models.py b/data/models.py index c794f00e..295ec08f 100644 --- a/data/models.py +++ b/data/models.py @@ -3,6 +3,9 @@ class Team(models.Model): name = models.CharField(max_length=200, default=None) + description = models.TextField(max_length=500, default=None, null=True) + members_count = models.PositiveSmallIntegerField(default=0) + increased_count = models.PositiveSmallIntegerField(default=0) def __str__(self): return self.name diff --git a/static/css/teams.css b/static/css/teams.css new file mode 100644 index 00000000..b73b1572 --- /dev/null +++ b/static/css/teams.css @@ -0,0 +1,17 @@ +.light-green-color { + color: green; +} + +.organization-teams { + margin: auto; + width: 60%; + min-width: 330px; +} + +.team-name { + font-size: 1.5em; +} + +.team-desc { + padding-left: 20px; +} diff --git a/static/js/main.js b/static/js/main.js index 9dabaa91..e1d4af0d 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -7,6 +7,18 @@ $(document).ready(function(){ var urlParams = new URLSearchParams(location.search); var formSubmitted = urlParams.get('form_submitted'); var formType = urlParams.get('form_type'); + var userAuthenticated = urlParams.get('auth'); + + var current_search_location = window.location; + console.log(current_search_location); + if(current_search_location.toString().search('teams')>0){ + var is_authenticated = Cookies.set('authenticated'); + var username = Cookies.set('username'); + if(is_authenticated !== true && username === undefined){ + window.location = window.location.origin + '?auth=false'; + } + } + if(formSubmitted==='True'){ var message = ''; if(formType==='login'){ @@ -29,6 +41,13 @@ $(document).ready(function(){ $('.important-message').text(message); $('.form-submission-popup').css('display', 'block'); } + else if(userAuthenticated === 'false'){ + $('.important-message').text( + 'You tried to access a webpage, which is available to only' + + ' authenticated users. Please join the community or Login(if' + + ' already a member of organization)'); + $('.form-submission-popup').css('display', 'block'); + } function activate_dropdown(){ if ($('nav').width() < 992 ){ @@ -43,7 +62,8 @@ $(document).ready(function(){ function check_user_authenticated_or_not() { if(Cookies.get('authenticated')){ - modify_html_elements('none', 'none','block', 'block', 'block'); + modify_html_elements('none', 'none','block', 'block', 'block', + 'block'); } } @@ -60,12 +80,13 @@ $(document).ready(function(){ function modify_html_elements(popup_form_display, login_option_display, profile_option_display, logout__option_display, - form_option_display) { + form_option_display, teams_option_display) { $('.form-popup').css('display', popup_form_display); login_user_el.css('display', login_option_display); $('.user-profile').css('display', profile_option_display); logout_user_el.css('display', logout__option_display); $('.forms-dropdown-option').css('display', form_option_display); + $('.teams-dropdown-option'.css('display', teams_option_display)); } function manipulate_web_page_data(oauth_provider, http_response_text) { @@ -74,7 +95,8 @@ $(document).ready(function(){ // Cookies expires in 3 days Cookies.set('authenticated', true, {expires: 3}); Cookies.set('username', json_data.user, {expires: 3}); - modify_html_elements('none', 'none','block', 'block', 'block'); + modify_html_elements('none', 'none','block', 'block', 'block', + 'block'); } else { display_error_message(oauth_provider, json_data.message); @@ -145,7 +167,7 @@ $(document).ready(function(){ logout_user_el.click(function () { Cookies.remove('authenticated'); Cookies.remove('username'); - modify_html_elements('none', 'block','none', 'none', 'none'); + modify_html_elements('none', 'block','none', 'none', 'none', 'none'); }); $('.login-with-github').click(function(e) { diff --git a/templates/base.html b/templates/base.html index aa55e9d0..6a8cf1c3 100644 --- a/templates/base.html +++ b/templates/base.html @@ -74,7 +74,7 @@
Team |
+ No. of Members |
+
---|---|
+
+
+ {{ team.name }}+{{ team.description }} + |
+ + {{ team.members_count }} + {% if team.increased_count > 0 %} + ( + + {{ team.increased_count }} members) + {% endif %} + | +
Note: The increased members count + refreshes every week.
+