From bf7a24cc6429ad7df64457a4258387a6ec154516 Mon Sep 17 00:00:00 2001 From: Stefan Dworschak Date: Fri, 5 Aug 2022 15:12:53 +0100 Subject: [PATCH 1/9] Adding competency app for participants to self-assess --- competencies/__init__.py | 0 competencies/admin.py | 3 + competencies/apps.py | 5 ++ competencies/forms.py | 20 ++++++ competencies/migrations/0001_initial.py | 57 ++++++++++++++++ .../migrations/0002_auto_20220805_1350.py | 22 ++++++ competencies/migrations/__init__.py | 0 competencies/models.py | 68 +++++++++++++++++++ .../competencies_self_assessment.html | 15 ++++ .../templates/competency_difficulty_form.html | 64 +++++++++++++++++ competencies/templates/competency_form.html | 39 +++++++++++ competencies/templates/list_competencies.html | 58 ++++++++++++++++ competencies/tests.py | 3 + competencies/urls.py | 17 +++++ competencies/views.py | 55 +++++++++++++++ docker-compose.yml | 4 +- main/settings.py | 1 + main/urls.py | 1 + static/css/style.css | 13 ++++ static/js/script.js | 22 ++++++ templates/base.html | 2 + templates/includes/navbar.html | 1 + 22 files changed, 469 insertions(+), 1 deletion(-) create mode 100644 competencies/__init__.py create mode 100644 competencies/admin.py create mode 100644 competencies/apps.py create mode 100644 competencies/forms.py create mode 100644 competencies/migrations/0001_initial.py create mode 100644 competencies/migrations/0002_auto_20220805_1350.py create mode 100644 competencies/migrations/__init__.py create mode 100644 competencies/models.py create mode 100644 competencies/templates/competencies_self_assessment.html create mode 100644 competencies/templates/competency_difficulty_form.html create mode 100644 competencies/templates/competency_form.html create mode 100644 competencies/templates/list_competencies.html create mode 100644 competencies/tests.py create mode 100644 competencies/urls.py create mode 100644 competencies/views.py diff --git a/competencies/__init__.py b/competencies/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/competencies/admin.py b/competencies/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/competencies/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/competencies/apps.py b/competencies/apps.py new file mode 100644 index 00000000..29035a59 --- /dev/null +++ b/competencies/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class CompetenciesConfig(AppConfig): + name = 'competencies' diff --git a/competencies/forms.py b/competencies/forms.py new file mode 100644 index 00000000..c9510eb6 --- /dev/null +++ b/competencies/forms.py @@ -0,0 +1,20 @@ +from django import forms + +from competencies.models import Competency, CompetencyDifficulty + +class CompetencyForm(forms.ModelForm): + perceived_difficulty = forms.ModelChoiceField( + queryset=CompetencyDifficulty.objects.all(), + widget=forms.Select(attrs={ + 'class': 'form-control' + })) + + class Meta: + model = Competency + fields = ['display_name', 'perceived_difficulty'] + + +class CompetencyDifficultyForm(forms.ModelForm): + class Meta: + model = CompetencyDifficulty + fields = ['display_name', 'numeric_difficulty'] diff --git a/competencies/migrations/0001_initial.py b/competencies/migrations/0001_initial.py new file mode 100644 index 00000000..3fd6227c --- /dev/null +++ b/competencies/migrations/0001_initial.py @@ -0,0 +1,57 @@ +# Generated by Django 3.1.13 on 2022-08-05 10:59 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='CompetencySelfAssessment', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created', models.DateTimeField(auto_now_add=True)), + ('updated', models.DateTimeField(auto_now=True)), + ('assessment_rating', models.CharField(blank=True, choices=[('want_to_know', 'Want to know about it'), ('learning', 'Learning about it right now'), ('know_it', 'I know about this')], default='', max_length=50, null=True)), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='competencies', to=settings.AUTH_USER_MODEL)), + ], + options={ + 'verbose_name': 'Competency Self Assessment', + 'verbose_name_plural': 'Competency Self Assessments', + }, + ), + migrations.CreateModel( + name='CompetencyDifficulty', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created', models.DateTimeField(auto_now_add=True)), + ('updated', models.DateTimeField(auto_now=True)), + ('display_name', models.CharField(default='', max_length=255)), + ('numeric_difficulty', models.FloatField(default=1.0)), + ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='created_competency_difficulties', to=settings.AUTH_USER_MODEL)), + ], + ), + migrations.CreateModel( + name='Competency', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created', models.DateTimeField(auto_now_add=True)), + ('updated', models.DateTimeField(auto_now=True)), + ('display_name', models.CharField(default='', max_length=255)), + ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='created_competencies', to=settings.AUTH_USER_MODEL)), + ('perceived_difficulty', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='competencies', to='competencies.competencydifficulty')), + ], + options={ + 'verbose_name': 'Competency', + 'verbose_name_plural': 'Competencies', + }, + ), + ] diff --git a/competencies/migrations/0002_auto_20220805_1350.py b/competencies/migrations/0002_auto_20220805_1350.py new file mode 100644 index 00000000..21e9f8fb --- /dev/null +++ b/competencies/migrations/0002_auto_20220805_1350.py @@ -0,0 +1,22 @@ +# Generated by Django 3.1.13 on 2022-08-05 13:50 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('competencies', '0001_initial'), + ] + + operations = [ + migrations.AlterModelOptions( + name='competencydifficulty', + options={'verbose_name': 'Competency Difficulty', 'verbose_name_plural': 'Competency Difficulties'}, + ), + migrations.AlterField( + model_name='competencydifficulty', + name='display_name', + field=models.CharField(default='', max_length=255, unique=True), + ), + ] diff --git a/competencies/migrations/__init__.py b/competencies/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/competencies/models.py b/competencies/models.py new file mode 100644 index 00000000..9df4216b --- /dev/null +++ b/competencies/models.py @@ -0,0 +1,68 @@ +from django.db import models + +from accounts.models import CustomUser as User + +ASSESSMENT_RATING_CHOICES = [ + ('want_to_know', 'Want to know about it'), + ('learning', 'Learning about it right now'), + ('know_it', 'I know about this'), +] + + +class CompetencyDifficulty(models.Model): + """ A percieved difficulty level of a competency or skill """ + created = models.DateTimeField(auto_now_add=True) + updated = models.DateTimeField(auto_now=True) + created_by = models.ForeignKey(User, + on_delete=models.CASCADE, + related_name="created_competency_difficulties") + + display_name = models.CharField(default="", max_length=255, unique=True) + numeric_difficulty = models.FloatField(default=1.0) + + def __str__(self): + return f'{self.display_name} - {self.numeric_difficulty}' + + class Meta: + verbose_name = 'Competency Difficulty' + verbose_name_plural = 'Competency Difficulties' + + +class Competency(models.Model): + """ A competency or skill that a user can make a self assessment for """ + created = models.DateTimeField(auto_now_add=True) + updated = models.DateTimeField(auto_now=True) + created_by = models.ForeignKey(User, + on_delete=models.CASCADE, + related_name="created_competencies") + + display_name = models.CharField(default="", max_length=255) + perceived_difficulty = models.ForeignKey(CompetencyDifficulty, + on_delete=models.CASCADE, + related_name="competencies") + + def __str__(self): + return self.display_name + + class Meta: + verbose_name = 'Competency' + verbose_name_plural = 'Competencies' + + +class CompetencySelfAssessment(models.Model): + created = models.DateTimeField(auto_now_add=True) + updated = models.DateTimeField(auto_now=True) + + user = models.ForeignKey(User, + on_delete=models.CASCADE, + related_name="competencies") + assessment_rating = models.CharField( + default="", max_length=50, choices=ASSESSMENT_RATING_CHOICES, + null=True, blank=True) + + def __str__(self): + return self.display_name + + class Meta: + verbose_name = 'Competency Self Assessment' + verbose_name_plural = 'Competency Self Assessments' diff --git a/competencies/templates/competencies_self_assessment.html b/competencies/templates/competencies_self_assessment.html new file mode 100644 index 00000000..e07a80bd --- /dev/null +++ b/competencies/templates/competencies_self_assessment.html @@ -0,0 +1,15 @@ +{% extends "base.html" %} +{% load static %} + +{% block content %} + + +{% if competencies %} + + +{% else %} +No competencies to self-assess available. +{% endif %} + + +{% endblock %} diff --git a/competencies/templates/competency_difficulty_form.html b/competencies/templates/competency_difficulty_form.html new file mode 100644 index 00000000..86380c04 --- /dev/null +++ b/competencies/templates/competency_difficulty_form.html @@ -0,0 +1,64 @@ +{% load static %} + + + + + Create New Difficulty Rating for Compentency + + + + + + + + + + + + {% include "includes/messages.html" %} + +
+
+
+ +
+
+
+

Create New Difficulty Rating for Compentency

+
+
+ +
+ {% csrf_token %} + {{ form.display_name|as_crispy_field }} + {{ form.numeric_difficulty|as_crispy_field }} + +
+ +
+
+
+ +
+
+
+ {% if messages %} + + {% endif %} + + + + + + diff --git a/competencies/templates/competency_form.html b/competencies/templates/competency_form.html new file mode 100644 index 00000000..1b64a255 --- /dev/null +++ b/competencies/templates/competency_form.html @@ -0,0 +1,39 @@ +{% extends "base.html" %} +{% load static %} + +{% block content %} + +
+
+ +
+
+
+

Create New Compentency for Participant Self-Assessment

+
+
+ +
+ {% csrf_token%} + {{form.display_name|as_crispy_field}} + +
+ {{form.perceived_difficulty}} + + + +
+ +
+ +
+
+
+ +
+
+ +{% url 'create_competency_difficulty' as create_competency_difficulty_url %} + + +{% endblock %} diff --git a/competencies/templates/list_competencies.html b/competencies/templates/list_competencies.html new file mode 100644 index 00000000..35f219db --- /dev/null +++ b/competencies/templates/list_competencies.html @@ -0,0 +1,58 @@ +{% extends "base.html" %} +{% load static %} + +{% block content %} + + +{% if competencies %} + +
+ + + + + + + + + + + + + {% for competency in competencies %} + + + + + + + + + {% endfor %} +
NamePerceived Difficulty# Want To Know About It# Learning It# Know ItActions
+ {{ competency.name }} + + {{ competency.perceived_difficulty }} + + + + + + + + + +
+
+ + +{% else %} +No competencies to self-assess available. +{% endif %} + + +{% endblock %} diff --git a/competencies/tests.py b/competencies/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/competencies/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/competencies/urls.py b/competencies/urls.py new file mode 100644 index 00000000..ef2cbb7b --- /dev/null +++ b/competencies/urls.py @@ -0,0 +1,17 @@ +from django.urls import path + +from competencies.views import self_assess_competencies, list_competencies, \ + create_competencies, edit_competencies, \ + create_competency_difficulty, \ + edit_competency_difficulty + +urlpatterns = [ + path('', self_assess_competencies, name="self_assess_competencies"), + path('list', list_competencies, name="list_competencies"), + path('create', create_competencies, name="create_competencies"), + path('edit', edit_competencies, name="edit_competencies"), + path('difficulty/create', create_competency_difficulty, + name="create_competency_difficulty"), + path('difficulty/edit', edit_competency_difficulty, + name="edit_competency_difficulty"), +] diff --git a/competencies/views.py b/competencies/views.py new file mode 100644 index 00000000..d05c2f29 --- /dev/null +++ b/competencies/views.py @@ -0,0 +1,55 @@ +from django.shortcuts import redirect, render, reverse +from django.contrib import messages + +from competencies.forms import CompetencyForm, CompetencyDifficultyForm +from competencies.models import Competency + + +def list_competencies(request): + competencies = Competency.objects.all() + return render(request, 'list_competencies.html', {'competencies': competencies}) + + +def create_competency_difficulty(request): + if request.method == 'POST': + form = CompetencyDifficultyForm(request.POST) + if form.is_valid(): + f = form.save(commit=False) + f.created_by = request.user + f.save() + messages.success(request, "Competency Difficulty created successfully.") + url = "%s?close_popup=true" % reverse('create_competency_difficulty') + return redirect(url) + else: + print(form.errors) + messages.error(request, form.errors) + return redirect(reverse('create_competency_difficulty')) + form = CompetencyDifficultyForm() + return render(request, 'competency_difficulty_form.html', {'form': form}) + else: + form = CompetencyDifficultyForm() + return render(request, 'competency_difficulty_form.html', {'form': form}) + + +def edit_competency_difficulty(request): + if request.method == 'POST': + pass + else: + form = CompetencyDifficultyForm() + return render(request, 'competency_difficulty_form.html', {'form': form}) + + +def create_competencies(request): + if request.method == 'POST': + pass + else: + form = CompetencyForm() + return render(request, 'competency_form.html', {'form': form}) + + +def edit_competencies(request): + return render(request, 'competency_form.html') + + +def self_assess_competencies(request): + return render(request, 'competencies_self_assessment.html') diff --git a/docker-compose.yml b/docker-compose.yml index 54136f36..e401b719 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,6 +10,7 @@ services: # code - ./accounts/:/hackathon-app/accounts/ + - ./competencies/:/hackathon-app/competencies/ - ./custom_slack_provider/:/hackathon-app/custom_slack_provider/ - ./hackadmin/:/hackathon-app/hackadmin/ - ./hackathon/:/hackathon-app/hackathon/ @@ -26,6 +27,7 @@ services: environment: - ENV_FILE=/hackathon-app/.env + - DEVELOPMENT=1 entrypoint: ['python3', 'manage.py', 'runserver', '0.0.0.0:8000'] ports: - "8000:8000" @@ -45,4 +47,4 @@ services: smtp: image: mailhog/mailhog:v1.0.1 ports: - - "8025:8025" + - "8026:8025" diff --git a/main/settings.py b/main/settings.py index 0a7a204f..5268a5c2 100644 --- a/main/settings.py +++ b/main/settings.py @@ -39,6 +39,7 @@ # custom apps "accounts", + "competencies", "hackathon", "hackadmin", "home", diff --git a/main/urls.py b/main/urls.py index 39719253..49329401 100644 --- a/main/urls.py +++ b/main/urls.py @@ -16,4 +16,5 @@ namespace='hackathon')), path("showcase/", include("showcase.urls")), path("teams/", include("teams.urls")), + path("competencies/", include("competencies.urls")), ] diff --git a/static/css/style.css b/static/css/style.css index c9e5f1b2..8a0d8662 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -811,6 +811,19 @@ img.showcase-image-edit { display:none; } +/* Competencies */ +.input-group.competency-difficulty-select select { + border-top-right-radius: 0; + border-bottom-right-radius: 0; +} + +.input-group.competency-difficulty-select a.btn { + border-top-left-radius: 0; + border-bottom-left-radius: 0; + margin: 0; + font-size: 1rem; +} + /* Media Queries */ @media (max-width:453px) { diff --git a/static/js/script.js b/static/js/script.js index 60f1c5e7..584ca895 100644 --- a/static/js/script.js +++ b/static/js/script.js @@ -26,6 +26,8 @@ $(document).ready(function(){ $(`#hackadmin-team-select-${hackathonId}`).show(); }); enableReviewsSlider(); + openCompetencyDifficultyInPopup(); + closePopup(); }); function setUpoadImageType(){ @@ -129,3 +131,23 @@ function enableReviewsSlider(){ } }); } + + +function openCompetencyDifficultyInPopup(){ + $('#openCompetencyDifficultyPopup').click(function(){ + // const params = `scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,width=500,height=350,left=-1000,top=-1000`; + const params = `width=500,height=350,left=-1000,top=-1000`; + const window_name = 'Create Competency Difficulty' + window.open(create_competency_difficulty_url, window_name, params); + }) +} + +function closePopup(){ + let queryString = window.location.search; + let urlParams = new URLSearchParams(queryString); + let close_popup = urlParams.get('close_popup') + if(close_popup){ + window.opener.location.reload(); + window.close(); + } +} diff --git a/templates/base.html b/templates/base.html index 0bb7f2f3..0df47c1d 100644 --- a/templates/base.html +++ b/templates/base.html @@ -15,6 +15,7 @@ + {% block css %} {% endblock %} @@ -68,6 +69,7 @@ + {{messages}} {% if messages %} +{% endblock %} diff --git a/teams/templatetags/teams_tags.py b/teams/templatetags/teams_tags.py index 9b76ae22..8f905e04 100644 --- a/teams/templatetags/teams_tags.py +++ b/teams/templatetags/teams_tags.py @@ -3,6 +3,7 @@ from django.template import Library from django.conf import settings +from django.core.exceptions import ObjectDoesNotExist register = Library() @@ -45,3 +46,11 @@ def extract_userid(username): def is_working_time(num): _num = int(num.split(':')[0]) return 8 <= _num <= 20 + + +@register.simple_tag +def get_participant_rating(participant, competency): + try: + return competency.get_user_rating(participant).rating + except (ObjectDoesNotExist, AttributeError): + return \ No newline at end of file diff --git a/teams/urls.py b/teams/urls.py index 301c653b..64c3e91a 100644 --- a/teams/urls.py +++ b/teams/urls.py @@ -1,7 +1,8 @@ from django.urls import path from .views import view_team, create_teams, clear_teams, create_project,\ - rename_team, create_group_im, view_team_calendar + rename_team, create_group_im, view_team_calendar, \ + view_team_competencies from showcase.views import create_or_update_showcase urlpatterns = [ @@ -15,6 +16,8 @@ path("/rename/", rename_team, name="rename_team"), path("/calendar/", view_team_calendar, name="view_team_calendar"), + path("/competencies/", view_team_competencies, + name="view_team_competencies"), path("create/", create_teams, name="create_teams"), path("clear/", clear_teams, name="clear_teams"), ] diff --git a/teams/views.py b/teams/views.py index e654f292..668d5682 100644 --- a/teams/views.py +++ b/teams/views.py @@ -13,6 +13,7 @@ from accounts.decorators import can_access from accounts.models import UserType from accounts.lists import TIMEZONE_CHOICES +from competencies.models import Competency from hackathon.models import Hackathon, HackTeam, HackProject from teams.helpers import choose_team_sizes, group_participants,\ choose_team_levels, find_all_combinations,\ @@ -321,3 +322,15 @@ def view_team_calendar(request, team_id): 'timezones': TIMEZONE_CHOICES, 'selected_timezone': timezone, }) + + +@login_required +def view_team_competencies(request, team_id): + hack_team = get_object_or_404(HackTeam, id=team_id) + competencies = Competency.objects.filter(is_visible=True) + redirect_url = reverse('view_team', kwargs={'team_id': team_id}) + return render(request, 'team_competencies.html', { + 'hack_team': hack_team, + 'competencies': competencies, + 'redirect_url': redirect_url, + }) \ No newline at end of file From dbf50590dd4dd527a36ad6927418ac9426a4542d Mon Sep 17 00:00:00 2001 From: Stefan Dworschak Date: Mon, 8 Aug 2022 15:55:37 +0100 Subject: [PATCH 4/9] Only retrieve assessement rating if visible --- competencies/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/competencies/models.py b/competencies/models.py index 3ccfdf72..b8778915 100644 --- a/competencies/models.py +++ b/competencies/models.py @@ -54,7 +54,8 @@ class Meta: def get_user_rating(self, user): try: return self.competency_assessment_ratings.get( - user_assessment__user=user) + user_assessment__user=user, + user_assessment__is_visible=True) except ObjectDoesNotExist: return From 7490b1e849505e34ced66136fee1492ddc2d5ff1 Mon Sep 17 00:00:00 2001 From: Stefan Dworschak Date: Mon, 8 Aug 2022 15:56:53 +0100 Subject: [PATCH 5/9] change label --- teams/templates/team.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/teams/templates/team.html b/teams/templates/team.html index 57388a6b..1540c46c 100644 --- a/teams/templates/team.html +++ b/teams/templates/team.html @@ -65,7 +65,7 @@

About the team

View Team Calendar - View Team Skills + View Competencies From 178e75ebd6431aa70649d009bec17d3be8d41586 Mon Sep 17 00:00:00 2001 From: Stefan Dworschak Date: Mon, 8 Aug 2022 16:06:12 +0100 Subject: [PATCH 6/9] Fixing some linting --- competencies/fixtures/competencies.json | 2 +- competencies/forms.py | 2 +- competencies/models.py | 1 - competencies/templates/competencies_self_assessment.html | 1 - competencies/templatetags/__init__.py | 0 competencies/templatetags/competencies_tags.py | 8 -------- teams/templates/team_competencies.html | 9 +++++++++ teams/templatetags/teams_tags.py | 2 +- teams/views.py | 2 +- templates/base.html | 1 - 10 files changed, 13 insertions(+), 15 deletions(-) delete mode 100644 competencies/templatetags/__init__.py delete mode 100644 competencies/templatetags/competencies_tags.py diff --git a/competencies/fixtures/competencies.json b/competencies/fixtures/competencies.json index 51e67d0c..900586c1 100644 --- a/competencies/fixtures/competencies.json +++ b/competencies/fixtures/competencies.json @@ -218,4 +218,4 @@ "is_visible": true } } -] \ No newline at end of file +] diff --git a/competencies/forms.py b/competencies/forms.py index ddb9a097..3c79b03d 100644 --- a/competencies/forms.py +++ b/competencies/forms.py @@ -47,4 +47,4 @@ class CompetencyAssessmentRatingForm(forms.ModelForm): })) class Meta: model = CompetencyAssessmentRating - fields = ['id', 'user_assessment', 'competency', 'rating'] \ No newline at end of file + fields = ['id', 'user_assessment', 'competency', 'rating'] diff --git a/competencies/models.py b/competencies/models.py index b8778915..1fa881a8 100644 --- a/competencies/models.py +++ b/competencies/models.py @@ -60,7 +60,6 @@ def get_user_rating(self, user): return - class CompetencyAssessment(models.Model): created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) diff --git a/competencies/templates/competencies_self_assessment.html b/competencies/templates/competencies_self_assessment.html index f532043b..422ac29b 100644 --- a/competencies/templates/competencies_self_assessment.html +++ b/competencies/templates/competencies_self_assessment.html @@ -1,6 +1,5 @@ {% extends "base.html" %} {% load static %} -{% load competencies_tags %} {% block content %} diff --git a/competencies/templatetags/__init__.py b/competencies/templatetags/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/competencies/templatetags/competencies_tags.py b/competencies/templatetags/competencies_tags.py deleted file mode 100644 index 7e4cf2b8..00000000 --- a/competencies/templatetags/competencies_tags.py +++ /dev/null @@ -1,8 +0,0 @@ -from django.template import Library - -register = Library() - - -@register.simple_tag -def get_user_rating(competency, user): - return competency.get_user_rating(user) diff --git a/teams/templates/team_competencies.html b/teams/templates/team_competencies.html index f84989cf..fe30403f 100644 --- a/teams/templates/team_competencies.html +++ b/teams/templates/team_competencies.html @@ -10,12 +10,21 @@ {% block content %} {% with authorised_types='SUPERUSER,STAFF,FACILITATOR_ADMIN,FACILITATOR_JUDGE,PARTNER_ADMIN,PARTNER_JUDGE' %} + + +
{% include 'includes/back_button.html' with redirect_url=redirect_url button_label='Back To The Team' %} +
+
+

Our Team's Competencies

+
+
+
diff --git a/teams/templatetags/teams_tags.py b/teams/templatetags/teams_tags.py index 8f905e04..ec9b2aae 100644 --- a/teams/templatetags/teams_tags.py +++ b/teams/templatetags/teams_tags.py @@ -53,4 +53,4 @@ def get_participant_rating(participant, competency): try: return competency.get_user_rating(participant).rating except (ObjectDoesNotExist, AttributeError): - return \ No newline at end of file + return diff --git a/teams/views.py b/teams/views.py index 668d5682..35a151e1 100644 --- a/teams/views.py +++ b/teams/views.py @@ -333,4 +333,4 @@ def view_team_competencies(request, team_id): 'hack_team': hack_team, 'competencies': competencies, 'redirect_url': redirect_url, - }) \ No newline at end of file + }) diff --git a/templates/base.html b/templates/base.html index 0df47c1d..e2572273 100644 --- a/templates/base.html +++ b/templates/base.html @@ -69,7 +69,6 @@ - {{messages}} {% if messages %} {% endif %} diff --git a/competencies/tests.py b/competencies/tests.py index 634ffd89..fdcfd9f0 100644 --- a/competencies/tests.py +++ b/competencies/tests.py @@ -1,11 +1,12 @@ from django.test import TestCase from accounts.models import CustomUser as User, Organisation -from competencies.helpers import get_or_create_competency_assessment, \ - populate_competency_assessment_for_formset -from competencies.models import Competency, CompetencyAssessment, \ - CompetencyDifficulty, \ - CompetencyAssessmentRating +from competencies.helpers import ( + get_or_create_competency_assessment, + populate_competency_assessment_for_formset) +from competencies.models import ( + Competency, CompetencyDifficulty, + CompetencyAssessment, CompetencyAssessmentRating) class CompetencyAssessmentTest(TestCase): @@ -19,7 +20,7 @@ def setUp(self): username="testuser2", slack_display_name="testuser2", ) - + self.assessment = CompetencyAssessment.objects.create( user=self.user2, is_visible=False, @@ -84,4 +85,4 @@ def test_get_user_rating(self): self.assertEquals(assessment.rating, 'know_it') assessment = self.competency2.get_user_rating(self.user2) - self.assertIsNone(assessment) \ No newline at end of file + self.assertIsNone(assessment) diff --git a/competencies/urls.py b/competencies/urls.py index f3ba5877..e4675e00 100644 --- a/competencies/urls.py +++ b/competencies/urls.py @@ -1,17 +1,17 @@ from django.urls import path -from competencies.views import self_assess_competencies, list_competencies, \ - create_competency, edit_competency, \ - create_competency_difficulty, \ - edit_competency_difficulty +from competencies import views + + urlpatterns = [ - path('', self_assess_competencies, name="self_assess_competencies"), - path('list', list_competencies, name="list_competencies"), - path('create', create_competency, name="create_competency"), - path('edit/', edit_competency, name="edit_competency"), - path('difficulty/create', create_competency_difficulty, + path('', views.self_assess_competencies, name="self_assess_competencies"), + path('list', views.list_competencies, name="list_competencies"), + path('create', views.create_competency, name="create_competency"), + path('edit/', views.edit_competency, + name="edit_competency"), + path('difficulty/create', views.create_competency_difficulty, name="create_competency_difficulty"), - path('difficulty/edit/', edit_competency_difficulty, - name="edit_competency_difficulty"), + path('difficulty/edit/', + views.edit_competency_difficulty, name="edit_competency_difficulty"), ] diff --git a/competencies/views.py b/competencies/views.py index 47cb47bd..e19396ce 100644 --- a/competencies/views.py +++ b/competencies/views.py @@ -3,15 +3,19 @@ from django.forms import modelformset_factory from django.shortcuts import get_object_or_404, redirect, render, reverse -from competencies.forms import CompetencyForm, CompetencyDifficultyForm, \ - CompetencyAssessmentForm, \ - CompetencyAssessmentRatingForm, RequiredModelFormSet -from competencies.helpers import get_or_create_competency_assessment, \ - populate_competency_assessment_for_formset -from competencies.models import Competency, CompetencyDifficulty, \ - CompetencyAssessment, \ - CompetencyAssessmentRating - +from competencies.forms import ( + CompetencyForm, CompetencyDifficultyForm, + CompetencyAssessmentForm, + CompetencyAssessmentRatingForm, + RequiredModelFormSet) + +from competencies.helpers import ( + get_or_create_competency_assessment, + populate_competency_assessment_for_formset) + +from competencies.models import ( + Competency, CompetencyDifficulty, + CompetencyAssessment, CompetencyAssessmentRating) def list_competencies(request): diff --git a/static/js/script.js b/static/js/script.js index 53116c63..00bd23e3 100644 --- a/static/js/script.js +++ b/static/js/script.js @@ -136,9 +136,8 @@ function enableReviewsSlider(){ function openCompetencyDifficultyInPopup(){ $('#openCompetencyDifficultyPopup').click(function(){ - // const params = `scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,width=500,height=350,left=-1000,top=-1000`; const params = `width=500,height=350,left=-1000,top=-1000`; - const window_name = 'Create Competency Difficulty' + const window_name = 'Create Competency Difficulty'; window.open(create_competency_difficulty_url, window_name, params); }) } @@ -146,7 +145,7 @@ function openCompetencyDifficultyInPopup(){ function closePopup(){ let queryString = window.location.search; let urlParams = new URLSearchParams(queryString); - let close_popup = urlParams.get('close_popup') + let close_popup = urlParams.get('close_popup'); if(close_popup){ window.opener.location.reload(); window.close(); @@ -155,15 +154,14 @@ function closePopup(){ function toggleCompetencyAssessmentIcon() { $('.competency-assessment-radio').change(function(){ - console.log($(this)) let current_selection = $(this).parent().parent().parent().find('label i[class$="-fill"]'); if(current_selection.length > 0){ _changeClass(current_selection[0]); } let new_selection = $(this).parent().find('label i'); _changeClass(new_selection[0]); - _chageSelection($(this).data('form'), $(this).data('rating')) - }) + _chageSelection($(this).data('form'), $(this).data('rating')); + }); } function _changeClass(element){ @@ -179,4 +177,4 @@ function _changeClass(element){ function _chageSelection(form_num, rating){ $(`#id_form-${form_num}-rating`).val(rating); -} \ No newline at end of file +} diff --git a/teams/urls.py b/teams/urls.py index 64c3e91a..741f820e 100644 --- a/teams/urls.py +++ b/teams/urls.py @@ -1,23 +1,22 @@ from django.urls import path -from .views import view_team, create_teams, clear_teams, create_project,\ - rename_team, create_group_im, view_team_calendar, \ - view_team_competencies +from . import views from showcase.views import create_or_update_showcase urlpatterns = [ - path("/", view_team, + path("/", views.view_team, name="view_team"), - path("/project/", create_project, name="create_project"), + path("/project/", views.create_project, + name="create_project"), path("/showcase/", create_or_update_showcase, name="create_or_update_showcase"), - path("/create_group_im/", create_group_im, + path("/create_group_im/", views.create_group_im, name="create_group_im"), - path("/rename/", rename_team, name="rename_team"), - path("/calendar/", view_team_calendar, + path("/rename/", views.rename_team, name="rename_team"), + path("/calendar/", views.view_team_calendar, name="view_team_calendar"), - path("/competencies/", view_team_competencies, + path("/competencies/", views.view_team_competencies, name="view_team_competencies"), - path("create/", create_teams, name="create_teams"), - path("clear/", clear_teams, name="clear_teams"), + path("create/", views.create_teams, name="create_teams"), + path("clear/", views.clear_teams, name="clear_teams"), ] diff --git a/teams/views.py b/teams/views.py index 35a151e1..0b5b5e06 100644 --- a/teams/views.py +++ b/teams/views.py @@ -15,11 +15,12 @@ from accounts.lists import TIMEZONE_CHOICES from competencies.models import Competency from hackathon.models import Hackathon, HackTeam, HackProject -from teams.helpers import choose_team_sizes, group_participants,\ - choose_team_levels, find_all_combinations,\ - distribute_participants_to_teams,\ - create_teams_in_view, update_team_participants, \ - calculate_timezone_offset +from teams.helpers import ( + choose_team_sizes, group_participants, + choose_team_levels, find_all_combinations, + distribute_participants_to_teams, + create_teams_in_view, update_team_participants, + calculate_timezone_offset) from teams.forms import HackProjectForm, EditTeamName SLACK_GROUP_IM_ENDPOINT = 'https://slack.com/api/conversations.open/' From 487bf7edb379a63e80dba2f5e44871d3c7818f33 Mon Sep 17 00:00:00 2001 From: Stefan Dworschak Date: Tue, 9 Aug 2022 13:03:18 +0100 Subject: [PATCH 9/9] Removing bootstrap icons, adding permissions to new views and fixing bug with no competencies --- .../competencies_self_assessment.html | 20 +++++++++--- .../templates/competency_difficulty_form.html | 1 - competencies/views.py | 32 +++++++++++++++++-- hackadmin/templates/hackadmin_panel.html | 3 +- static/css/style.css | 21 ++++++++++-- static/js/script.js | 12 +++---- teams/templates/team_competencies.html | 8 ++--- templates/base.html | 1 - 8 files changed, 75 insertions(+), 23 deletions(-) diff --git a/competencies/templates/competencies_self_assessment.html b/competencies/templates/competencies_self_assessment.html index 422ac29b..783f2f94 100644 --- a/competencies/templates/competencies_self_assessment.html +++ b/competencies/templates/competencies_self_assessment.html @@ -45,25 +45,37 @@

Self-Assess Your Competencies

- +
- +
- +
- +
diff --git a/competencies/templates/competency_difficulty_form.html b/competencies/templates/competency_difficulty_form.html index dbd7d789..7c189b8d 100644 --- a/competencies/templates/competency_difficulty_form.html +++ b/competencies/templates/competency_difficulty_form.html @@ -7,7 +7,6 @@ -