Allow moving an event from one team to another. Fixes #120
This commit is contained in:
parent
3cd1e314e3
commit
de814e2b03
8 changed files with 81 additions and 26 deletions
|
@ -345,6 +345,13 @@ class CancelEventForm(forms.Form):
|
|||
confirm = forms.BooleanField(label="Yes, cancel this event", required=True)
|
||||
reason = forms.CharField(label=_("Reason for cancellation"), widget=forms.widgets.Textarea)
|
||||
|
||||
class ChangeEventHostForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Event
|
||||
fields = [
|
||||
'team'
|
||||
]
|
||||
|
||||
class EventInviteMemberForm(forms.Form):
|
||||
member = forms.ChoiceField(label=_(""))
|
||||
|
||||
|
|
4
events/templates/events/change_team_form.html
Normal file
4
events/templates/events/change_team_form.html
Normal file
|
@ -0,0 +1,4 @@
|
|||
<table>
|
||||
{{ change_form }}
|
||||
</table>
|
||||
|
|
@ -40,7 +40,15 @@ form {
|
|||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
.gt-profile {
|
||||
position: relative;
|
||||
}
|
||||
.gt-profile .gt-profile-badges {
|
||||
position: absolute;
|
||||
top: 24px;
|
||||
left: 6px;
|
||||
|
||||
}
|
||||
.btn-googleplus {
|
||||
color: #FFFFFF;
|
||||
background-color: #DB4437;
|
||||
|
|
24
get_together/templates/get_together/events/change_team.html
Normal file
24
get_together/templates/get_together/events/change_team.html
Normal file
|
@ -0,0 +1,24 @@
|
|||
{% extends "get_together/base.html" %}
|
||||
{% load static %}
|
||||
{% block content %}
|
||||
<h2>Change host for: {{event.name}}</h2>
|
||||
<p>Select which of your teams you would like to host this event.</p>
|
||||
<form action="{% url "change-team" event.id %}" enctype="multipart/form-data" method="post">
|
||||
{% csrf_token %}
|
||||
{% include "events/change_team_form.html" %}
|
||||
<br />
|
||||
<button type="submit" class="btn btn-primary">Change</button>
|
||||
<a class="btn btn-secondary" href="{{event.get_absolute_url}}">Cancel</a>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block javascript %}
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
|
||||
$("#id_team").selectmenu();
|
||||
});
|
||||
|
||||
</script>
|
||||
{% endblock %}
|
|
@ -14,19 +14,10 @@
|
|||
{% block styles %}
|
||||
<link href="{% static 'css/bootstrap-album.css' %}" rel="stylesheet"/>
|
||||
<style>
|
||||
.gt-profile {
|
||||
position: relative;
|
||||
}
|
||||
.gt-profile .gt-profile-badges {
|
||||
position: relative;
|
||||
top: 16px;
|
||||
left: -42px;
|
||||
}
|
||||
textarea {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
|
@ -155,6 +146,7 @@ textarea {
|
|||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="editMenuButton">
|
||||
<a href="{% url 'edit-event' event.id %}" class="dropdown-item">Event Details</a>
|
||||
<a href="{% url 'change-team' event.id %}" class="dropdown-item">Change Host</a>
|
||||
<a href="{% url 'manage-event-sponsors' event.id %}" class="dropdown-item">Manage Sponsors</a>
|
||||
<a href="{% url 'schedule-event-talks' event.id %}" class="dropdown-item">Manage Talks</a>
|
||||
<a href="{% url 'manage-attendees' event.id %}" class="dropdown-item">Manage Attendees</a>
|
||||
|
@ -298,9 +290,9 @@ textarea {
|
|||
{% for attendee in attendee_list %}
|
||||
<div class="row mb-3">
|
||||
<div class="col media gt-profile">
|
||||
<img class="mr-1 gt-profile-avatar" src="{{attendee.user.avatar_url}}" width="32px" height="32px">
|
||||
<span class="gt-profile-badges">{% for badge in attendee.user.user.account.badges.all %}<img class="mr-0 gt-profile-badge" src="{{badge.img_url}}" title="{{badge.name}}" width="16px" height="16px">{% endfor %}</span>
|
||||
<div class="media-body">
|
||||
<img class="mr-1 gt-profile-avatar" src="{{attendee.user.avatar_url}}" width="32px" height="32px">
|
||||
<span class="gt-profile-badges">{% for badge in attendee.user.user.account.badges.all %}<img class="mr-0 gt-profile-badge" src="{{badge.img_url}}" title="{{badge.name}}" width="16px" height="16px">{% endfor %}</span>
|
||||
<div class="media-body">
|
||||
<h6 class="mt-2 mb-0">
|
||||
<a href="{% url 'show-profile' attendee.user.id %}" title="{{attendee.user}}'s profile">{{attendee.user}}</a>
|
||||
{% if attendee.user.user == request.user and not event.is_over %}
|
||||
|
|
|
@ -3,20 +3,6 @@
|
|||
|
||||
{% block add_to_title %} | {{team.name}}{% endblock %}
|
||||
|
||||
{% block styles %}
|
||||
<style>
|
||||
.gt-profile {
|
||||
position: relative;
|
||||
}
|
||||
.gt-profile .gt-profile-badges {
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
left: 6px;
|
||||
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="fluid-container container-primary">
|
||||
<div class="row">
|
||||
|
|
|
@ -85,6 +85,7 @@ urlpatterns = [
|
|||
path('events/<int:event_id>/+new-event-team/', views.new_event_add_team, name='new-event-add-team'),
|
||||
|
||||
path('events/<int:event_id>/+edit/', views.edit_event, name='edit-event'),
|
||||
path('events/<int:event_id>/+host/', views.change_event_host, name='change-team'),
|
||||
path('events/<int:event_id>/+attend/', views.attend_event, name='attend-event'),
|
||||
path('events/<int:event_id>/+attended/', views.attended_event, name='attended-event'),
|
||||
path('events/<int:event_id>/+attendees/', views.manage_attendees, name='manage-attendees'),
|
||||
|
|
|
@ -40,6 +40,7 @@ from events.forms import (
|
|||
EventInviteMemberForm,
|
||||
EventContactForm,
|
||||
SponsorForm,
|
||||
ChangeEventHostForm,
|
||||
)
|
||||
from events import location
|
||||
from events.utils import verify_csrf
|
||||
|
@ -670,6 +671,38 @@ def edit_event(request, event_id):
|
|||
else:
|
||||
return redirect('home')
|
||||
|
||||
@login_required
|
||||
def change_event_host(request, event_id):
|
||||
event = get_object_or_404(Event, id=event_id)
|
||||
if not request.user.profile.can_edit_event(event):
|
||||
messages.add_message(request, messages.WARNING, message=_('You can not change this event\'s host'))
|
||||
return redirect(event.get_absolute_url())
|
||||
|
||||
if request.method == 'GET':
|
||||
form = ChangeEventHostForm(instance=event)
|
||||
form.fields['team'].queryset = Team.objects.filter(member__user=request.user.profile, member__role__gte=Member.MODERATOR).order_by('name')
|
||||
|
||||
context = {
|
||||
'event': event,
|
||||
'change_form': form,
|
||||
}
|
||||
return render(request, 'get_together/events/change_team.html', context)
|
||||
elif request.method == 'POST':
|
||||
form = ChangeEventHostForm(request.POST, instance=event)
|
||||
form.fields['team'].queryset = Team.objects.filter(member__user=request.user.profile, member__role__gte=Member.MODERATOR).order_by('name')
|
||||
if form.is_valid():
|
||||
new_event = form.save()
|
||||
messages.add_message(request, messages.SUCCESS, message=_('Your event host has been changed.'))
|
||||
return redirect(new_event.get_absolute_url())
|
||||
else:
|
||||
context = {
|
||||
'event': event,
|
||||
'change_form': form,
|
||||
}
|
||||
return render(request, 'get_together/orgs/request_to_join.html', context)
|
||||
else:
|
||||
return redirect('home')
|
||||
|
||||
@login_required
|
||||
def delete_event(request, event_id):
|
||||
event = get_object_or_404(Event, id=event_id)
|
||||
|
|
Loading…
Reference in a new issue