From f077badf3163fc36c111dc45fe8d7d6f57d8712a Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Fri, 8 Nov 2013 09:31:01 +0200 Subject: Merged motor and checkin --- apps/core/__init__.py | 0 apps/core/admin.py | 3 +++ apps/core/forms.py | 12 +++++++++ apps/core/models.py | 59 ++++++++++++++++++++++++++++++++++++++++++ apps/core/templates/login.html | 2 ++ apps/core/tests.py | 3 +++ apps/core/views.py | 17 ++++++++++++ 7 files changed, 96 insertions(+) create mode 100644 apps/core/__init__.py create mode 100644 apps/core/admin.py create mode 100644 apps/core/forms.py create mode 100644 apps/core/models.py create mode 100644 apps/core/templates/login.html create mode 100644 apps/core/tests.py create mode 100644 apps/core/views.py (limited to 'apps/core') diff --git a/apps/core/__init__.py b/apps/core/__init__.py new file mode 100644 index 0000000..e69de29 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' -- cgit v1.2.3