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)
|
confirm = forms.BooleanField(label="Yes, cancel this event", required=True)
|
||||||
reason = forms.CharField(label=_("Reason for cancellation"), widget=forms.widgets.Textarea)
|
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):
|
class EventInviteMemberForm(forms.Form):
|
||||||
member = forms.ChoiceField(label=_(""))
|
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;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
}
|
}
|
||||||
|
.gt-profile {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.gt-profile .gt-profile-badges {
|
||||||
|
position: absolute;
|
||||||
|
top: 24px;
|
||||||
|
left: 6px;
|
||||||
|
|
||||||
|
}
|
||||||
.btn-googleplus {
|
.btn-googleplus {
|
||||||
color: #FFFFFF;
|
color: #FFFFFF;
|
||||||
background-color: #DB4437;
|
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 %}
|
{% block styles %}
|
||||||
<link href="{% static 'css/bootstrap-album.css' %}" rel="stylesheet"/>
|
<link href="{% static 'css/bootstrap-album.css' %}" rel="stylesheet"/>
|
||||||
<style>
|
<style>
|
||||||
.gt-profile {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
.gt-profile .gt-profile-badges {
|
|
||||||
position: relative;
|
|
||||||
top: 16px;
|
|
||||||
left: -42px;
|
|
||||||
}
|
|
||||||
textarea {
|
textarea {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -155,6 +146,7 @@ textarea {
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu" aria-labelledby="editMenuButton">
|
<div class="dropdown-menu" aria-labelledby="editMenuButton">
|
||||||
<a href="{% url 'edit-event' event.id %}" class="dropdown-item">Event Details</a>
|
<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 '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 'schedule-event-talks' event.id %}" class="dropdown-item">Manage Talks</a>
|
||||||
<a href="{% url 'manage-attendees' event.id %}" class="dropdown-item">Manage Attendees</a>
|
<a href="{% url 'manage-attendees' event.id %}" class="dropdown-item">Manage Attendees</a>
|
||||||
|
@ -298,9 +290,9 @@ textarea {
|
||||||
{% for attendee in attendee_list %}
|
{% for attendee in attendee_list %}
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col media gt-profile">
|
<div class="col media gt-profile">
|
||||||
<img class="mr-1 gt-profile-avatar" src="{{attendee.user.avatar_url}}" width="32px" height="32px">
|
<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>
|
<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">
|
<div class="media-body">
|
||||||
<h6 class="mt-2 mb-0">
|
<h6 class="mt-2 mb-0">
|
||||||
<a href="{% url 'show-profile' attendee.user.id %}" title="{{attendee.user}}'s profile">{{attendee.user}}</a>
|
<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 %}
|
{% if attendee.user.user == request.user and not event.is_over %}
|
||||||
|
|
|
@ -3,20 +3,6 @@
|
||||||
|
|
||||||
{% block add_to_title %} | {{team.name}}{% endblock %}
|
{% 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 %}
|
{% block content %}
|
||||||
<div class="fluid-container container-primary">
|
<div class="fluid-container container-primary">
|
||||||
<div class="row">
|
<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>/+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>/+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>/+attend/', views.attend_event, name='attend-event'),
|
||||||
path('events/<int:event_id>/+attended/', views.attended_event, name='attended-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'),
|
path('events/<int:event_id>/+attendees/', views.manage_attendees, name='manage-attendees'),
|
||||||
|
|
|
@ -40,6 +40,7 @@ from events.forms import (
|
||||||
EventInviteMemberForm,
|
EventInviteMemberForm,
|
||||||
EventContactForm,
|
EventContactForm,
|
||||||
SponsorForm,
|
SponsorForm,
|
||||||
|
ChangeEventHostForm,
|
||||||
)
|
)
|
||||||
from events import location
|
from events import location
|
||||||
from events.utils import verify_csrf
|
from events.utils import verify_csrf
|
||||||
|
@ -670,6 +671,38 @@ def edit_event(request, event_id):
|
||||||
else:
|
else:
|
||||||
return redirect('home')
|
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
|
@login_required
|
||||||
def delete_event(request, event_id):
|
def delete_event(request, event_id):
|
||||||
event = get_object_or_404(Event, id=event_id)
|
event = get_object_or_404(Event, id=event_id)
|
||||||
|
|
Loading…
Reference in a new issue