aboutsummaryrefslogtreecommitdiffstats
path: root/apps/core
diff options
context:
space:
mode:
authorFilipp Lepalaan <f@230.to>2013-11-08 09:31:01 +0200
committerFilipp Lepalaan <f@230.to>2013-11-08 09:31:01 +0200
commitf077badf3163fc36c111dc45fe8d7d6f57d8712a (patch)
treef2b83bdc836f8a8035badb0d401ee0ea86eafa55 /apps/core
parentb9fc1060406a433473faa70c236ba3e177640d26 (diff)
downloadmotor.old-f077badf3163fc36c111dc45fe8d7d6f57d8712a.tar.gz
motor.old-f077badf3163fc36c111dc45fe8d7d6f57d8712a.tar.bz2
motor.old-f077badf3163fc36c111dc45fe8d7d6f57d8712a.zip
Merged motor and checkin
Diffstat (limited to 'apps/core')
-rw-r--r--apps/core/__init__.py0
-rw-r--r--apps/core/admin.py3
-rw-r--r--apps/core/forms.py12
-rw-r--r--apps/core/models.py59
-rw-r--r--apps/core/templates/login.html2
-rw-r--r--apps/core/tests.py3
-rw-r--r--apps/core/views.py17
7 files changed, 96 insertions, 0 deletions
diff --git a/apps/core/__init__.py b/apps/core/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/apps/core/__init__.py
diff --git a/apps/core/admin.py b/apps/core/admin.py
new file mode 100644
index 0000000..8c38f3f
--- /dev/null
+++ b/apps/core/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/apps/core/forms.py b/apps/core/forms.py
new file mode 100644
index 0000000..66a6287
--- /dev/null
+++ b/apps/core/forms.py
@@ -0,0 +1,12 @@
+from django import forms
+
+
+class LoginForm(forms.Form):
+ username = forms.CharField(widget=forms.TextInput(attrs={
+ 'class': 'form-control',
+ 'placeholder': 'Email address'
+ }))
+ password = forms.CharField(widget=forms.PasswordInput(attrs={
+ 'class': 'form-control',
+ 'placeholder': 'password'
+ }))
diff --git a/apps/core/models.py b/apps/core/models.py
new file mode 100644
index 0000000..04d7582
--- /dev/null
+++ b/apps/core/models.py
@@ -0,0 +1,59 @@
+import uuid
+from django.db import models
+from django.contrib.contenttypes import generic
+from django.contrib.auth.models import AbstractUser
+from django.contrib.contenttypes.models import ContentType
+
+from django.template.defaultfilters import slugify
+
+
+class ServiceProvider(models.Model):
+ uuid = models.CharField(
+ unique=True,
+ max_length=36,
+ default=lambda: str(uuid.uuid4())
+ )
+ BACKEND_CHOICES = (
+ ('http', 'HTTP'),
+ ('smtp', 'SMTP'),
+ ('servo', 'Servo')
+ )
+ backend_type = models.CharField(
+ max_length=6,
+ default='servo',
+ choices=BACKEND_CHOICES
+ )
+ name = models.CharField(
+ max_length=128,
+ default='Apple Service Provider'
+ )
+ http_url = models.URLField(null=True, blank=True)
+ http_username = models.CharField(max_length=128, null=True, blank=True)
+ http_password = models.CharField(max_length=128, null=True, blank=True)
+ smtp_address = models.EmailField(null=True, blank=True)
+ servo_url = models.URLField(null=True, blank=True)
+
+
+class User(AbstractUser):
+ sp = models.ForeignKey(ServiceProvider, null=True)
+
+
+class TaggedItem(models.Model):
+ "A generic tagged item"
+ tag = models.CharField(max_length=128)
+ slug = models.SlugField()
+ kind = models.CharField(max_length=64, default='')
+
+ object_id = models.PositiveIntegerField()
+ content_type = models.ForeignKey(ContentType)
+ content_object = generic.GenericForeignKey("content_type", "object_id")
+
+ def save(self, *args, **kwargs):
+ self.slug = slugify(self.tag)
+ super(TaggedItem, self).save(*args, **kwargs)
+
+ def __unicode__(self):
+ return self.tag
+
+ class Meta:
+ unique_together = ("content_type", "object_id", "tag",)
diff --git a/apps/core/templates/login.html b/apps/core/templates/login.html
new file mode 100644
index 0000000..5f53b32
--- /dev/null
+++ b/apps/core/templates/login.html
@@ -0,0 +1,2 @@
+{% extends 'default.html' %}
+
diff --git a/apps/core/tests.py b/apps/core/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/apps/core/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/apps/core/views.py b/apps/core/views.py
new file mode 100644
index 0000000..fc8f941
--- /dev/null
+++ b/apps/core/views.py
@@ -0,0 +1,17 @@
+from django.shortcuts import render
+from django.views.generic.edit import FormView
+from django.views.generic.list import ListView
+from apps.core.forms import LoginForm
+
+from apps.core.models import ServiceProvider
+
+
+class LoginView(FormView):
+ template_name = 'login.html'
+ form_class = LoginForm
+ success_url = '/manage/sites/'
+
+
+class SitesListView(ListView):
+ model = ServiceProvider
+ template_name = 'manage/sites.html'