diff --git a/events/forms.py b/events/forms.py
index 94aafc6..8327f58 100644
--- a/events/forms.py
+++ b/events/forms.py
@@ -38,7 +38,6 @@ class Lookup(TextInput):
self.source = source
self.key = key
self.label = label
- self.name = 'place'
def get_context(self, name, value, attrs):
context = super().get_context(name, value, attrs)
@@ -47,8 +46,14 @@ class Lookup(TextInput):
context['widget']['label'] = self.label
return context
+ def format_value(self, value):
+ if value is not None:
+ return mark_safe('' % (value, _('No change')))
+ else:
+ return mark_safe('')
+
class DateWidget(DateInput):
- """A more-friendly date widget with a pop-up calendar.
+ """A more-friendly date widget with a p% if widget.value != None %} value="{{ widget.value|stringformat:'s' }}"{% endif %op-up calendar.
"""
template_name = 'forms/widgets/date.html'
def __init__(self, attrs=None):
@@ -144,7 +149,13 @@ class DateTimeWidget(SplitDateTimeWidget):
class TeamForm(ModelForm):
class Meta:
model = Team
- fields = '__all__'
+ fields = ['name', 'country', 'spr', 'city', 'web_url', 'tz']
+ widgets = {
+ 'country': Lookup(source='/api/country/', label='name'),
+ 'spr': Lookup(source='/api/spr/', label='name'),
+ 'city': Lookup(source='/api/cities/', label='name'),
+ }
+ raw_id_fields = ('country','spr','city')
class NewTeamForm(ModelForm):
class Meta:
@@ -162,9 +173,9 @@ class TeamEventForm(ModelForm):
model = Event
fields = ['name', 'start_time', 'end_time', 'summary', 'place', 'web_url', 'announce_url', 'tags']
widgets = {
- 'country': Lookup(source='/api/country/', label='name'),
- 'spr': Lookup(source='/api/spr/', label='name'),
- 'city': Lookup(source='/api/cities/', label='name'),
+ 'place': Lookup(source='/api/places/', label='name'),
+ 'start_time': DateTimeWidget,
+ 'end_time': DateTimeWidget
}
class NewTeamEventForm(ModelForm):
diff --git a/events/templates/events/event_details.html b/events/templates/events/event_details.html
index 7affe44..aa31537 100644
--- a/events/templates/events/event_details.html
+++ b/events/templates/events/event_details.html
@@ -4,6 +4,9 @@
Time: | {{ event.start_time }} - {{ event.end_time }} |
Place: | {{ event.place }} |
+
+ Host: | {{ event.created_by }} |
+
{% if event.web_url %}
Website: | {{ event.web_url }} |
diff --git a/events/templates/forms/widgets/lookup.html b/events/templates/forms/widgets/lookup.html
index 14e719d..92bbcdc 100644
--- a/events/templates/forms/widgets/lookup.html
+++ b/events/templates/forms/widgets/lookup.html
@@ -1,5 +1,5 @@
diff --git a/get_together/templates/get_together/base.html b/get_together/templates/get_together/base.html
index 58800c2..feb84fc 100644
--- a/get_together/templates/get_together/base.html
+++ b/get_together/templates/get_together/base.html
@@ -19,6 +19,9 @@ body {
.starter-template {
padding: 3rem 1.5rem;
text-align: center;
+}
+form {
+ display: inline;
}
diff --git a/get_together/templates/get_together/edit_event.html b/get_together/templates/get_together/edit_event.html
new file mode 100644
index 0000000..534f5a3
--- /dev/null
+++ b/get_together/templates/get_together/edit_event.html
@@ -0,0 +1,43 @@
+{% extends "get_together/base.html" %}
+
+{% block content %}
+Updating {{event.name}}
+
+{% endblock %}
+
+{% block javascript %}
+
+{% endblock %}
diff --git a/get_together/templates/get_together/edit_team.html b/get_together/templates/get_together/edit_team.html
new file mode 100644
index 0000000..a23e939
--- /dev/null
+++ b/get_together/templates/get_together/edit_team.html
@@ -0,0 +1,51 @@
+{% extends "get_together/base.html" %}
+
+{% block content %}
+Update {{team.name}}
+
+{% endblock %}
+
+{% block javascript %}
+
+
+{% endblock %}
diff --git a/get_together/templates/get_together/show_event.html b/get_together/templates/get_together/show_event.html
index 70d49d6..3567b71 100644
--- a/get_together/templates/get_together/show_event.html
+++ b/get_together/templates/get_together/show_event.html
@@ -6,5 +6,10 @@
{% include "events/event_details.html" %}
+{% if request.user.profile == event.created_by %}
+
+{% endif %}
{% endblock %}
diff --git a/get_together/templates/get_together/show_team.html b/get_together/templates/get_together/show_team.html
index 7a1c2e6..85e87d4 100644
--- a/get_together/templates/get_together/show_team.html
+++ b/get_together/templates/get_together/show_team.html
@@ -10,6 +10,10 @@
+
+
{% endif %}
{% endblock %}
diff --git a/get_together/urls.py b/get_together/urls.py
index c2cde78..227a0ee 100644
--- a/get_together/urls.py
+++ b/get_together/urls.py
@@ -31,7 +31,9 @@ urlpatterns = [
path('create-team/', views.create_team, name='create-team'),
path('teams/', views.teams_list, name='teams'),
path('team//', views.show_team, name='show-team'),
+ path('team//edit/', views.edit_team, name='edit-team'),
path('team//create-event/', views.create_event, name='create-event'),
+ path('events//edit/', views.edit_event, name='edit-event'),
path('events///', views.show_event, name='show-event'),
path('places/', views.places_list, name='places'),
diff --git a/get_together/views.py b/get_together/views.py
index 231baff..c15a79c 100644
--- a/get_together/views.py
+++ b/get_together/views.py
@@ -51,6 +51,32 @@ def create_team(request, *args, **kwargs):
else:
return redirect('home')
+def edit_team(request, team_id):
+ team = Team.objects.get(id=team_id)
+ if request.method == 'GET':
+ form = TeamForm(instance=team)
+
+ context = {
+ 'team': team,
+ 'team_form': form,
+ }
+ return render(request, 'get_together/edit_team.html', context)
+ elif request.method == 'POST':
+ form = TeamForm(request.POST, instance=team)
+ if form.is_valid:
+ new_team = form.save()
+ new_team.owner_profile = request.user.profile
+ new_team.save()
+ return redirect('show-team', team_id=new_team.pk)
+ else:
+ context = {
+ 'team': team,
+ 'team_form': form,
+ }
+ return render(request, 'get_together/edit_team.html', context)
+ else:
+ return redirect('home')
+
def teams_list(request, *args, **kwargs):
teams = Team.objects.all()
context = {
@@ -69,6 +95,32 @@ def show_team(request, team_id, *args, **kwargs):
}
return render(request, 'get_together/show_team.html', context)
+def edit_event(request, event_id):
+ event = Event.objects.get(id=event_id)
+ if request.method == 'GET':
+ form = TeamEventForm(instance=event)
+
+ context = {
+ 'team': event.team,
+ 'event': event,
+ 'event_form': form,
+ }
+ return render(request, 'get_together/edit_event.html', context)
+ elif request.method == 'POST':
+ form = TeamEventForm(request.POST,instance=event)
+ if form.is_valid:
+ new_event = form.save()
+ return redirect(new_event.get_absolute_url())
+ else:
+ context = {
+ 'team': event.team,
+ 'event': event,
+ 'event_form': form,
+ }
+ return render(request, 'get_together/edit_event.html', context)
+ else:
+ return redirect('home')
+
def create_event(request, team_id):
team = Team.objects.get(id=team_id)
if request.method == 'GET':