Skip to content

Commit

Permalink
hopefully show emails
Browse files Browse the repository at this point in the history
  • Loading branch information
AliengirlLiv committed Mar 31, 2018
1 parent d2d5964 commit 9dcfa57
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
17 changes: 17 additions & 0 deletions hvz/main/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from django.utils import timezone
from django.utils.decorators import method_decorator
from django.views import generic
from django.http import HttpResponse

from hvz.main import decorators, forms, mixins, models

Expand Down Expand Up @@ -258,6 +259,22 @@ def json_population_time_series(request):
{'label': 'zombies', 'data': zombie_tally, 'color': 'rgb(0, 128, 0)'},
])

def json_get_all_emails(request):
"""A function that displays all emails.
"""
emails = [p.user.email for p in Player.current_players()]

# json.dumps creates a string from a Python object.
json_data = json.dumps(emails)

return HttpResponse(
json_data,
content_type="application/json"
)

def success(request):
return render(request, 'api/success.html', {})


def time_endpoints(game):
"""Return the start and end times of the game.
Expand Down
2 changes: 2 additions & 0 deletions hvz/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
path('register/', views.RegisterView.as_view(), name='register'),
path('register/success', views.register_success),

path('emails/', views.json_get_all_emails, name='emails'),

path('status/', views.PopStatPage.as_view(), name='stats_index'),
path('status/tags', views.MealLog.as_view(), name='stats_meal_log'),
path('status/outbreak', views.OutbreakPage.as_view(), name='stats_outbreak'),
Expand Down

0 comments on commit 9dcfa57

Please sign in to comment.