Intitial teams support #147
38
teams/templates/teams/confirm_leave.html
Normal file
38
teams/templates/teams/confirm_leave.html
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{% extends "common/base.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
{% block content %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col col-md-8 mx-auto my-4">
|
||||||
|
<div class="box">
|
||||||
|
<h2>
|
||||||
|
{% blocktranslate with team_name=object.name %}Leave team {{ team_name }}?{% endblocktranslate %}
|
||||||
|
</h2>
|
||||||
|
<p>
|
||||||
|
{% if will_lose_access_to %}
|
||||||
|
{% blocktranslate %}
|
||||||
|
You will lose access to all team extensions that were not uploaded by you:
|
||||||
|
{% endblocktranslate %}
|
||||||
|
<ul>
|
||||||
|
{% for extension in will_lose_access_to %}
|
||||||
|
<li><a href="{{ extension.get_absolute_url }}">{{ extension }}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
</p>
|
||||||
|
<div class="btn-row-fluid">
|
||||||
|
<a href="#" class="btn js-btn-back">
|
||||||
|
<i class="i-cancel"></i>
|
||||||
|
<span>{% trans 'Cancel' %}</span>
|
||||||
|
</a>
|
||||||
|
<form method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
<button type="submit" class="btn btn-block btn-danger">
|
||||||
|
<i class="i-log-out"></i>
|
||||||
|
<span>{% trans 'Confirm Leave' %}</span>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock content %}
|
@ -45,9 +45,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu dropdown-menu-right js-dropdown-menu" id="team-{{ team.id }}">
|
<ul class="dropdown-menu dropdown-menu-right js-dropdown-menu" id="team-{{ team.id }}">
|
||||||
<li>
|
<li>
|
||||||
{# TODO: @back-end add page leave team base and link #}
|
<a class="dropdown-item {% comment %}dropdown-item-disabled{% endcomment %}" href="{% url 'teams:leave-team' slug=team.slug %}"><i class="i-log-out"></i>Leave Team</a>
|
||||||
{# TODO: @back-end add conditional class 'dropdown-item-disabled' if user is the only manager #}
|
|
||||||
<a class="dropdown-item {% comment %}dropdown-item-disabled{% endcomment %}" href="#"><i class="i-log-out"></i>Leave Team</a>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -5,4 +5,9 @@ import teams.views
|
|||||||
app_name = 'teams'
|
app_name = 'teams'
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('settings/teams/', teams.views.TeamsView.as_view(), name='list'),
|
path('settings/teams/', teams.views.TeamsView.as_view(), name='list'),
|
||||||
|
path(
|
||||||
|
'settings/leave-team/<slug:slug>/',
|
||||||
|
teams.views.LeaveTeamView.as_view(),
|
||||||
|
name='leave-team',
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
@ -1,12 +1,35 @@
|
|||||||
"""Team pages."""
|
"""Team pages."""
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
|
from django.shortcuts import redirect
|
||||||
from django.views.generic import ListView
|
from django.views.generic import ListView
|
||||||
|
from django.views.generic.detail import DetailView
|
||||||
|
|
||||||
import teams.models
|
from extensions.models import Extension
|
||||||
|
from teams.models import Team, TeamsUsers
|
||||||
|
|
||||||
|
|
||||||
class TeamsView(LoginRequiredMixin, ListView):
|
class TeamsView(LoginRequiredMixin, ListView):
|
||||||
model = teams.models.Team
|
model = Team
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return self.request.user.teams.all()
|
return self.request.user.teams.all()
|
||||||
|
|
||||||
|
|
||||||
|
class LeaveTeamView(LoginRequiredMixin, DetailView):
|
||||||
|
model = Team
|
||||||
|
template_name = 'teams/confirm_leave.html'
|
||||||
|
|
||||||
|
def post(self, request, *args, **kwargs):
|
||||||
|
team = self.get_object()
|
||||||
|
team_user = TeamsUsers.objects.filter(team=team, user=self.request.user).first()
|
||||||
|
team_user.delete()
|
||||||
|
return redirect('teams:list')
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
context['will_lose_access_to'] = list(
|
||||||
|
Extension.objects.authored_by(self.request.user)
|
||||||
|
.exclude(maintainer__user_id=self.request.user.pk)
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
return context
|
||||||
|
Loading…
Reference in New Issue
Block a user