1. powersurge360
  2. groupGo

Commits

Zach Woodward  committed b93802b

Modified models, urls and views to accept new templates

  • Participants
  • Parent commits 6e15d61
  • Branches master

Comments (0)

Files changed (3)

File groupGo/apps/organizations/models.py

View file
             self.longitude = location['lng']
         super(Organization, self).save(*args, **kwargs)
 
+    def __str__(self):
+        return self.name
+
 
 class CarPooler(models.Model):
     name = models.CharField(max_length=254)

File groupGo/apps/organizations/urls.py

View file
 from django.conf.urls import patterns, url
 from apps.organizations.views import (
-    MapView, AddOrg, OrganizationListAPIView, OrganizationDetailAPIView,
+    MapView, AddOrgView, AddCarView, OrganizationListAPIView, OrganizationDetailAPIView,
     CarPoolerListAPIView, CarPoolerDetailAPIView,
 )
 
 urlpatterns = patterns(
     '',
     url(r'^$', MapView.as_view(), name='map'),
-    url(r'^add$', AddOrg.as_view(), name='add'),
+    url(r'^addOrg$', AddOrgView.as_view(), name='addOrg'),
+    url(r'^addCar$', AddCarView.as_view(), name='addCar'),
     url(
         r'^api/organizations$',
         OrganizationListAPIView.as_view(),

File groupGo/apps/organizations/views.py

View file
-from django.views.generic import TemplateView
+from django.views.generic import TemplateView, CreateView
 from rest_framework import generics
 
 from .models import Organization, CarPooler
 class MapView(TemplateView):
     template_name = "organizations/map.html"
 
-class AddOrg(TemplateView):
-	template_name = "organizations/organization.html"
+class AddOrgView(CreateView):
+    model = Organization
+    template_name = "organizations/organization.html"
+    success_url = "/organizations"
 
+class AddCarView(CreateView):
+    model = CarPooler
+    template_name = "organizations/carpoolers.html"
+    success_url = "/organizations"
 
 class OrganizationListAPIView(generics.ListCreateAPIView):
     queryset = Organization.objects.all()