Index: django_apps/foobar/admin.py
===================================================================
--- django_apps/foobar/admin.py	(revision 302)
+++ django_apps/foobar/admin.py	(revision 302)
@@ -0,0 +1,18 @@
+from foobar.models import *
+from django.contrib import admin
+
+class AlertInline(admin.TabularInline):
+  model = Alert
+  extra = 0
+  max_num = 0
+  can_delete = False
+  readonly_fields = ('service',)
+  fields = ('service', 'enable')
+
+class RoleAdmin(admin.ModelAdmin):
+  inlines = [ AlertInline, ]
+  class Media:
+    css = { "all" : ("css/hide_admin_original.css",) }
+admin.site.register(Role, RoleAdmin)
+admin.site.register(Service)
+#admin.site.register(Alert)
Index: django_apps/foobar/models.py
===================================================================
--- django_apps/foobar/models.py	(revision 302)
+++ django_apps/foobar/models.py	(revision 302)
@@ -0,0 +1,35 @@
+from django.db import models
+
+# Create your models here.
+class Role(models.Model):
+  name = models.CharField(max_length=50)
+  def __unicode__(self):
+    return self.name
+
+  def save(self, *args, **kwargs):
+    is_new = self.id is None
+    super(Role, self).save(*args, **kwargs)
+    if is_new:
+      for service in Service.objects.all():
+        alert = Alert(role=self, service=service, enable=False)
+        alert.save()
+
+class Service(models.Model):
+  name = models.CharField(max_length=50)
+  def __unicode__(self):
+    return self.name
+
+  def save(self, *args, **kwargs):
+    is_new = self.id is None
+    super(Service, self).save(*args, **kwargs)
+    if is_new:
+      for role in Role.objects.all():
+        alert = Alert(role=role, service=self, enable=False)
+        alert.save()
+
+class Alert(models.Model):
+  enable = models.BooleanField()
+  role = models.ForeignKey(Role)
+  service = models.ForeignKey(Service)
+  class Meta:
+    unique_together = (('role', 'service'))
Index: django_apps/foobar/templates/foobar/index.html
===================================================================
--- django_apps/foobar/templates/foobar/index.html	(revision 302)
+++ django_apps/foobar/templates/foobar/index.html	(revision 302)
@@ -0,0 +1,45 @@
+<html>
+<head></head><body>
+<table border='1'>
+<tr>
+<td></td>
+{% for role in role_list %}
+<td>{{ role }}</td>
+{% endfor %}
+</tr>
+{% for service in service_list %}
+<tr>
+<td>{{ service }}</td>
+{% for role in role_list %}
+<td>{{ rile }}</td>
+{% endfor %}
+</tr>
+{% endfor %}
+</table>
+
+<form action=""  method="post">
+  {% csrf_token %}
+<input type="hidden" name="roles" value="{{ data.roles }}"</input>
+<input type="hidden" name="services" value="{{ data.services }}"</input>
+
+<table border='1'>
+{% for role, values in data.data.items %}
+  {% if forloop.first %}
+    <tr>
+    <td></td>
+    {% for service in values.keys %}
+    <td>{{ service }}</td>
+    {% endfor %}
+    </tr>
+  {% endif %}
+  <tr><td>{{role}}</td>
+  {% for service, enable in values.items %}
+    <td><input name="{{role}}-{{service}}" type="checkbox" {% if enable %}checked="1"{% endif %} /></td>
+  {% endfor %}
+  </tr>
+{% endfor %}
+</table>
+<input type="submit" />
+</form>
+</body></html>
+
Index: django_apps/foobar/tests.py
===================================================================
--- django_apps/foobar/tests.py	(revision 302)
+++ django_apps/foobar/tests.py	(revision 302)
@@ -0,0 +1,16 @@
+"""
+This file demonstrates writing tests using the unittest module. These will pass
+when you run "manage.py test".
+
+Replace this with more appropriate tests for your application.
+"""
+
+from django.test import TestCase
+
+
+class SimpleTest(TestCase):
+    def test_basic_addition(self):
+        """
+        Tests that 1 + 1 always equals 2.
+        """
+        self.assertEqual(1 + 1, 2)
Index: django_apps/foobar/urls.py
===================================================================
--- django_apps/foobar/urls.py	(revision 302)
+++ django_apps/foobar/urls.py	(revision 302)
@@ -0,0 +1,13 @@
+from django.conf.urls.defaults import patterns, include, url
+
+urlpatterns = patterns('',
+    # Uncomment the admin/doc line below to enable admin documentation:
+    url(r'^$', 'foobar.views.index'),
+    # url(r'^user/(.+)/$', 'running.views.user_index'),
+    # url(r'^zoom/$', 'running.views.zoom'),
+    # url(r'^json/user/column/(\d+)/$', 'running.views.json_user_column'),
+    # url(r'^json/user/total/(\d+)/$', 'running.views.json_user_total'),
+    # url(r'^json/user/speed/(\d+)/$', 'running.views.json_user_speed'),
+    # url(r'^accounts/login/$', 'django.contrib.auth.views.login', name='login' ),
+    # url(r'^accounts/logout/$', 'django.contrib.auth.views.logout', name='logout'),
+)
Index: django_apps/foobar/views.py
===================================================================
--- django_apps/foobar/views.py	(revision 302)
+++ django_apps/foobar/views.py	(revision 302)
@@ -0,0 +1,38 @@
+from django.core import serializers
+from django.http import HttpResponse
+from django.template import RequestContext
+
+from django.shortcuts import render_to_response, get_object_or_404
+from foobar.models import Service, Role, Alert
+
+from django.forms import ModelForm
+from django.forms.models import modelformset_factory
+
+
+
+# Create your views here.
+def index(request):
+  if request.POST.has_key('roles'):
+    for role in request.POST['roles'].split(','):
+      for service in request.POST['services'].split(','):
+         alert = Alert.objects.get(role__name=role,service__name=service)
+         if request.POST.has_key('%s-%s' % (role, service)):
+           alert.enable = True
+         else:
+           alert.enable = False
+         alert.save()
+
+  service_list = Service.objects.all()
+  role_list = Role.objects.all()
+  alert_list = Alert.objects.all()
+  AlertFormSet = modelformset_factory(Alert, extra=0)
+  formset = AlertFormSet(queryset=Alert.objects.all())
+  data = { 'data' : {},
+           'roles' : ','.join(map(str,Role.objects.all())),
+           'services' : ','.join(map(str,Service.objects.all()))}
+  for role in role_list:
+    data['data'][role] = {}
+    for service in service_list:
+       data['data'][role][service] = Alert.objects.get(role=role,service=service).enable
+
+  return render_to_response('foobar/index.html', { 'service_list' : service_list, 'role_list' : role_list, 'alert_list' : alert_list, 'formset' : formset, 'data' : data }, context_instance=RequestContext(request))
Index: django_apps/settings.py
===================================================================
--- django_apps/settings.py	(revision 301)
+++ django_apps/settings.py	(revision 302)
@@ -121,4 +121,6 @@
     'django.contrib.admindocs',
     'django_apps.running',
+    'django_apps.foobar',
+    'django_extensions',
 )
 
Index: django_apps/urls.py
===================================================================
--- django_apps/urls.py	(revision 301)
+++ django_apps/urls.py	(revision 302)
@@ -6,8 +6,13 @@
 admin.autodiscover()
 
+from django.contrib import databrowse
+from running.models import User, Result
+databrowse.site.register(User)
+databrowse.site.register(Result)
+
 urlpatterns = patterns('',
     # Examples:
     # url(r'^$', 'foobar.views.home', name='home'),
-    # url(r'^foobar/', include('foobar.foo.urls')),
+    url(r'^foobar/', include('django_apps.foobar.urls')),
     url(r'^running/', include('django_apps.running.urls')),
 
@@ -17,4 +22,6 @@
     # Uncomment the next line to enable the admin:
     url(r'^admin/', include(admin.site.urls)),
+    (r'^accounts/login/$', 'django.contrib.auth.views.login'),
+    (r'^accounts/logout/$', 'django.contrib.auth.views.logout'),
 )
 
