...
 
Commits (2)
from django.contrib import admin
from .models import Event
# Register your models here.
admin.site.register(Event)
\ No newline at end of file
# Generated by Django 2.1.1 on 2018-09-22 03:35
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Event',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('uniqueid', models.IntegerField()),
('title', models.CharField(max_length=120)),
('locations', models.CharField(max_length=100)),
('description', models.CharField(max_length=100)),
('starttimeiso', models.CharField(max_length=25)),
('dayofweek', models.CharField(max_length=9)),
('duration', models.CharField(max_length=5)),
],
),
]
......@@ -8,10 +8,9 @@
MasonToday API
</h1>
<p>
We have two APIs available, pulled from two different sources of GMU events:
You can check out the following avenues for accessing the events happening on campus:
<ul>
<li>Get Connected: <a href="/api/getconnected">masontoday.gmu.io/api/getconnected</a></li>
<li>25 Live: <a href="/api/25live">masontoday.gmu.io/api/25live</a></li>
<li>Get Connected: <a href="/api/rawdata">masontoday.gmu.edu/api/rawdata</a></li>
</ul>
</p>
<p>
......
......@@ -3,5 +3,6 @@ from django.urls import path
from . import views
urlpatterns = [
path('', views.apiwelcome, name='apiwelcome')
path('', views.apiwelcome, name='apiwelcome'),
path('rawdata/', views.rawdata, name='rawdata')
]
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from .models import Event
import json
# Create your views here.
def apiwelcome(request):
return render(request, 'api/apiwelcome.html')
\ No newline at end of file
return render(request, 'api/apiwelcome.html')
def rawdata(request):
if Event.objects.all() == False:
return HttpResponse("There are no events! --DEBUG")
eventlist = []
for event in Event.objects.all():
eventlist.append({
'uniqueid': event.uniqueid,
'title': event.title,
'locations': event.locations,
'description': event.description,
'starttimeiso': event.starttimeiso,
'dayofweek': event.dayofweek,
'duration': event.duration
})
return HttpResponse(json.dumps(eventlist, ensure_ascii=False), content_type="application/json")
\ No newline at end of file