diff --git a/main/admin.py b/main/admin.py index 226cf6bf..a55dd4b3 100644 --- a/main/admin.py +++ b/main/admin.py @@ -25,6 +25,8 @@ Provider, Skill, SkillLevel, + Team, + TeamMembership, ToolLanguageMethodology, User, UserSkill, @@ -222,3 +224,13 @@ def has_delete_permission( ) -> bool: """Do not allow deleting users from this view.""" return False + + +@admin.register(Team) +class TeamAdmin(admin.ModelAdmin[Team]): + """Admin class for the Team model.""" + + +@admin.register(TeamMembership) +class TeamMembershipAdmin(admin.ModelAdmin[TeamMembership]): + """Admin class for the TeamMembership model.""" diff --git a/main/forms.py b/main/forms.py index b9c4fae1..9b79c112 100644 --- a/main/forms.py +++ b/main/forms.py @@ -16,6 +16,8 @@ RegistrationFormUniqueEmail, ) +from main import models + from .models import Skill, SkillLevel, UserSkill if TYPE_CHECKING: # pragma: no cover @@ -269,3 +271,13 @@ def save(self, user: "UserType") -> tuple[list[UserSkill], list[UserSkill]]: created_skills.append(user_skill) return created_skills, updated_skills + + +class CreateTeamForm(forms.Form): + """Form for creating a new team.""" + + class Meta: + """Meta options for CreateTeamForm.""" + + model = models.Team + fields = "__all__" diff --git a/main/models/__init__.py b/main/models/__init__.py index bc3dd610..9b5b9210 100644 --- a/main/models/__init__.py +++ b/main/models/__init__.py @@ -2,4 +2,5 @@ from .community_models import * # noqa: F403 from .framework_models import * # noqa: F403 +from .team_models import * # noqa: F403 from .user_models import * # noqa: F403 diff --git a/main/models/team_models.py b/main/models/team_models.py new file mode 100644 index 00000000..67e80114 --- /dev/null +++ b/main/models/team_models.py @@ -0,0 +1,14 @@ +from django.conf import settings +from django.db import models + +from .framework_models import SluggedModel + + +class Team(SluggedModel): + pass + + +class TeamMembership(models.Model): + user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) + team = models.ForeignKey(Team, on_delete=models.CASCADE) + manager = models.BooleanField(blank=True, default=False) diff --git a/main/models/user_models.py b/main/models/user_models.py index 1b23295e..9fe20054 100644 --- a/main/models/user_models.py +++ b/main/models/user_models.py @@ -30,3 +30,17 @@ class Meta: constraints = ( models.UniqueConstraint(fields=["user", "skill"], name="unique_user_skill"), ) + + +class Team(models.Model): + """Model for representing a team of users working together.""" + + name = models.CharField(max_length=255) + manager = models.ForeignKey( + settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="managed_teams" + ) + members = models.ManyToManyField(settings.AUTH_USER_MODEL, related_name="teams") + + def __str__(self) -> str: + """Return the string representation of the team.""" + return self.name diff --git a/main/templates/main/pages/create-team.html b/main/templates/main/pages/create-team.html new file mode 100644 index 00000000..463d4f8e --- /dev/null +++ b/main/templates/main/pages/create-team.html @@ -0,0 +1,14 @@ +{% extends "main/base.account.html" %} +{% load crispy_forms_tags %} +{% block content %} +
+

+ Create Team +

+
+ {% csrf_token %} + {{ form|crispy }} + +
+
+{% endblock content %} diff --git a/main/templates/main/pages/my-teams.html b/main/templates/main/pages/my-teams.html new file mode 100644 index 00000000..64cd7f3a --- /dev/null +++ b/main/templates/main/pages/my-teams.html @@ -0,0 +1,67 @@ +{% extends "main/base.page.html" %} +{% load static %} +{% block title %} + DIRECT Framework - My Teams +{% endblock title %} +{% block breadcrumb_items %} + + +{% endblock breadcrumb_items %} +{% block content %} +
+
+
+

My Teams

+ Create Team +

+ This page presents the teams you are in in the Digital Research + Competencies Framework. +

+ + + + + + + + + + + {% for team in teams %} + + + + + + + {% endfor %} + +
Team NameDescriptionManagerMembers
+ {{ team.name }} + {{ team.description }}{{ team.manager }} +
    + {% for member in team.members %}
  • {{ member }}
  • {% endfor %} +
+
+
+ +
+
+{% endblock content %} diff --git a/main/templates/main/snippets/navbar.html b/main/templates/main/snippets/navbar.html index 7fe8970b..d07274b1 100644 --- a/main/templates/main/snippets/navbar.html +++ b/main/templates/main/snippets/navbar.html @@ -38,6 +38,10 @@