Permalink
Browse files

add asterisk project and fix up config files so both projects functio…

…n properly
  • Loading branch information...
1 parent 0cf1399 commit 29eae58d015fbbc0a098faa3ff21f49d3ae23172 @robottrouble robottrouble committed Sep 13, 2010
View
No changes.
View
@@ -0,0 +1,7 @@
+from hive76_apps.asterisk.models import *
+from django.contrib import admin
+
+
+admin.site.register(UserDetails)
+admin.site.register(CallBack)
+admin.site.register(FailedAuth)
View
@@ -0,0 +1,38 @@
+from django.db import models
+from django.contrib.auth.models import User
+# Create your models here.
+
+class UserDetails(models.Model):
+ asterisk_extension = models.CharField(max_length=4)
+ access_code = models.CharField(max_length=4)
+ access_message = models.CharField(max_length=2048)
+ phone_number = models.CharField(max_length=10)
+ user = models.OneToOneField(User, related_name="details")
+
+ def __unicode__(self):
+ return self.user.username
+
+class CallBack(models.Model):
+ user = models.ForeignKey(User, related_name="calls")
+ time = models.DateTimeField()
+ returned = models.BooleanField(default=False)
+
+ def __unicode__(self):
+ retstr = "User: %d Time: %s Returned: %s" % (self.user.id, self.time, self.returned)
+ return retstr
+
+class FailedAuth(models.Model):
+ method = models.CharField(max_length=4)
+ data = models.CharField(max_length=4)
+ time = models.DateTimeField()
+
+ def assign(self, user):
+ if self.method == 'AST':
+ user.details.access_code = self.data
+ elif self.method == 'SMS':
+ user.details.access_message = self.data
+ user.details.save()
+
+ def __unicode__(self):
+ retstr = "ID: %d Time: %s Data: %s" % (self.id, self.time, self.data)
+ return retstr
@@ -0,0 +1,7 @@
+<html>
+<body>
+{{ timestamp }}
+<br>
+{{ response }}
+</body>
+</html>
View
@@ -0,0 +1,17 @@
+# Create your views here.
+import time, datetime
+from django.contrib.auth.models import User
+from hackerspace_management.asterisk.models import *
+from django.shortcuts import render_to_response
+
+def callback_add(request, authCode):
+ try:
+ u = User.objects.get(details__access_code = authCode)
+ callback = CallBack(user=u, time=datetime.datetime.now())
+ callback.save()
+ retstr = "Calling Back: %s" % (callback.user.details.phone_number)
+ except:
+ retstr = "Authentication Error"
+
+ timestamp = "Time: %s" % (datetime.datetime.now())
+ return render_to_response('callback_add.html', {'response': retstr, 'timestamp': timestamp})
View
@@ -1,4 +1,4 @@
-from hive76_inventory.inventory.models import *
+from hackerspace_management.inventory.models import *
from django.forms import ModelForm
class PartsForm(ModelForm):
View
@@ -6,8 +6,8 @@
from django.shortcuts import render_to_response
from django.template.loader import get_template
from django.template import Context
-from hive76_inventory.inventory.models import *
-from hive76_inventory.inventory.modelforms import *
+from hackerspace_management.inventory.models import *
+from hackerspace_management.inventory.modelforms import *
from django.contrib.auth.decorators import login_required
from django.core.paginator import Paginator, InvalidPage, EmptyPage
from django.contrib.auth import logout
View
@@ -0,0 +1 @@
+python manage.py syncdb --noinput && chown www-data:www-data ./hackerspace_management.db && chmod 775 ./hackerspace_management.db && python manage.py runserver localhost:8000
View
14 urls.py
@@ -1,13 +1,18 @@
from django.conf.urls.defaults import *
from django.conf import settings
-from hive76_inventory.inventory.views import *
+from django.contrib import admin
+from hackerspace_management.inventory.views import *
+from hackerspace_management.asterisk.views import *
+
+admin.autodiscover()
+
urlpatterns = patterns('',
# Example:
- # (r'^hive76_inventory/', include('hive76_inventory.foo.urls')),
+ # (r'^hackerspace_management/', include('hackerspace_management.foo.urls')),
# Uncomment this for admin:
(r'^$', parts_view_all),
- (r'^admin/', include('django.contrib.admin.urls')),
+ (r'^admin/(.*)', admin.site.root),
(r'^locations/$', locations_view_all),
(r'^locations/new/$', locations_add),
(r'^locations/view/(\d+)/$', locations_view),
@@ -28,5 +33,6 @@
(r'^stock/edit/(\d+)/$', stock_add_edit),
(r'^reports/$', reports_view_all),
(r'^accounts/login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}),
- (r'^accounts/logout/$', logout_view)
+ (r'^accounts/logout/$', logout_view),
+ (r'^auth/add/(\d+)/$', callback_add),
)

0 comments on commit 29eae58

Please sign in to comment.