diff --git a/events/admin.py b/events/admin.py
index 4aa87f2..40de86d 100644
--- a/events/admin.py
+++ b/events/admin.py
@@ -43,5 +43,6 @@ class EventAdmin(admin.ModelAdmin):
admin.site.register(Event, EventAdmin)
admin.site.register(Member)
+admin.site.register(Attendee)
diff --git a/events/models/events.py b/events/models/events.py
index cc33d23..584bfb4 100644
--- a/events/models/events.py
+++ b/events/models/events.py
@@ -147,5 +147,17 @@ class Attendee(models.Model):
event = models.ForeignKey(Event, on_delete=models.CASCADE)
user = models.ForeignKey(UserProfile, on_delete=models.CASCADE)
role = models.SmallIntegerField(_("Role"), choices=ROLES, default=NORMAL, db_index=True)
- status = models.SmallIntegerField(_("Attending?"), choices=STATUSES, db_index=True)
+ status = models.SmallIntegerField(_("Attending?"), choices=STATUSES, default=YES, db_index=True)
joined_date = models.DateTimeField(default=datetime.datetime.now)
+
+ @property
+ def role_name(self):
+ return Attendee.ROLES[self.role][1]
+
+ @property
+ def status_name(self):
+ return Attendee.STATUSES[self.status+1][1]
+
+ def __str__(self):
+ return "%s at %s" % (self.user, self.event)
+
diff --git a/events/templates/events/attendee_list.html b/events/templates/events/attendee_list.html
new file mode 100644
index 0000000..aaf09f6
--- /dev/null
+++ b/events/templates/events/attendee_list.html
@@ -0,0 +1,15 @@
+
+{% if attendee_list %}
+
+ {% for attendee in attendee_list %}
+
+ {{ attendee.user }} |
+ {{ attendee.status_name }} |
+ {% if attendee.role > 0 %}{{ attendee.role_name }}{% endif %} |
+
+ {% endfor %}
+
+{% else %}
+ No attendees yet.
+{% endif %}
+
diff --git a/events/templates/events/event_list.html b/events/templates/events/event_list.html
index 55df1aa..5418df1 100644
--- a/events/templates/events/event_list.html
+++ b/events/templates/events/event_list.html
@@ -4,9 +4,8 @@
{% for event in events_list %}
{{ event.name }} |
- {{ event.team.name }} |
- {{ event.start_time }} |
{{ event.place }} |
+ {{ event.start_time }} |
{% endfor %}
diff --git a/events/views.py b/events/views.py
index 1eb83a0..6491d10 100644
--- a/events/views.py
+++ b/events/views.py
@@ -7,7 +7,7 @@ from rest_framework.decorators import api_view, throttle_classes
from rest_framework.response import Response
from .models.search import Searchable, SearchableSerializer
-from .models.events import Event, Place, PlaceSerializer
+from .models.events import Event, Place, PlaceSerializer, Attendee
from .models.locale import Country ,CountrySerializer, SPR, SPRSerializer, City, CitySerializer
from .models.profiles import Team, UserProfile, Member
@@ -98,3 +98,15 @@ def leave_team(request, team_id):
messages.add_message(request, messages.SUCCESS, message=_('You are no longer on this team.'))
return redirect('show-team', team_id=team_id)
+def attend_event(request, event_id):
+ event = Event.objects.get(id=event_id)
+ if request.user.is_anonymous:
+ messages.add_message(request, messages.WARNING, message=_("You must be logged in to say you're attending."))
+ return redirect(event.get_absolute_url())
+ if request.user.profile in event.attendees.all():
+ messages.add_message(request, messages.INFO, message=_('You are already attending this event.'))
+ return redirect(event.get_absolute_url())
+ new_attendee = Attendee.objects.create(event=event, user=request.user.profile, role=Attendee.NORMAL, status=Attendee.YES)
+ messages.add_message(request, messages.SUCCESS, message=_("We'll see you there!"))
+ return redirect(event.get_absolute_url())
+
diff --git a/get_together/templates/get_together/show_event.html b/get_together/templates/get_together/show_event.html
index bf4c7d4..26b97f4 100644
--- a/get_together/templates/get_together/show_event.html
+++ b/get_together/templates/get_together/show_event.html
@@ -5,7 +5,17 @@
{% include "events/event_details.html" %}
+
+Attendees ({{attendee_list.count}})
+{% include "events/attendee_list.html" with attendee_list=attendee_list %}
+
+
+{% if not is_attending %}
+
+{% endif %}
{% if can_edit_event %}