diff --git a/stregsystem/fembers/__init__.py b/stregsystem/fembers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/stregsystem/fembers/admin.py b/stregsystem/fembers/admin.py new file mode 100644 index 0000000..a4b9f80 --- /dev/null +++ b/stregsystem/fembers/admin.py @@ -0,0 +1,15 @@ +from django.contrib import admin + +from fembers.models import Member, List + + +class MemberAdmin(admin.ModelAdmin): + exclude = ('number',) + + +class ListAdmin(admin.ModelAdmin): + pass + + +admin.site.register(Member, MemberAdmin) +admin.site.register(List, ListAdmin) diff --git a/stregsystem/fembers/migrations/0001_initial.py b/stregsystem/fembers/migrations/0001_initial.py new file mode 100644 index 0000000..6d648c8 --- /dev/null +++ b/stregsystem/fembers/migrations/0001_initial.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='List', + fields=[ + ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True, serialize=False)), + ('name', models.CharField(max_length=64)), + ], + options={ + }, + bases=(models.Model,), + ), + migrations.CreateModel( + name='Member', + fields=[ + ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True, serialize=False)), + ('username', models.CharField(blank=True, null=True, max_length=64)), + ('name', models.CharField(default='', max_length=64)), + ('number', models.IntegerField()), + ('join_date', models.DateTimeField(auto_now_add=True)), + ('active', models.BooleanField(default=True)), + ('_pin', models.CharField(verbose_name='pin', blank=True, null=True, max_length=128)), + ('note', models.TextField(blank=True)), + ('email', models.EmailField(max_length=75)), + ('_phone_number', models.CharField(verbose_name='phone number', blank=True, max_length=16)), + ], + options={ + }, + bases=(models.Model,), + ), + migrations.AddField( + model_name='list', + name='members', + field=models.ManyToManyField(to='fembers.Member'), + preserve_default=True, + ), + ] diff --git a/stregsystem/fembers/migrations/__init__.py b/stregsystem/fembers/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/stregsystem/fembers/models.py b/stregsystem/fembers/models.py new file mode 100644 index 0000000..4d4ac6d --- /dev/null +++ b/stregsystem/fembers/models.py @@ -0,0 +1,30 @@ +from django.db import models + + +class Member(models.Model): + username = models.CharField(max_length=64, null=True, blank=True) + name = models.CharField(max_length=64, default='') + number = models.IntegerField() + join_date = models.DateTimeField(auto_now_add=True) + active = models.BooleanField(default=True) + _pin = models.CharField(verbose_name="pin", + max_length=128, + blank=True, + null=True) + note = models.TextField(blank=True) + email = models.EmailField() + _phone_number = models.CharField(verbose_name="phone number", + max_length=16, + blank=True, + validators=[]) + + def __str__(self): + return str.format("{s.username} #{s.number} ({s.name})", s=self) + + +class List(models.Model): + name = models.CharField(max_length=64) + members = models.ManyToManyField(Member) + + def __str__(self): + return self.name diff --git a/stregsystem/fembers/test/__init__.py b/stregsystem/fembers/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/stregsystem/products/__init__.py b/stregsystem/products/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/stregsystem/products/admin.py b/stregsystem/products/admin.py new file mode 100644 index 0000000..6090aa8 --- /dev/null +++ b/stregsystem/products/admin.py @@ -0,0 +1,8 @@ +from django.contrib import admin + +from products.models import Product, PointOfSale, Listing, Tag + +admin.site.register(Product) +admin.site.register(PointOfSale) +admin.site.register(Listing) +admin.site.register(Tag) diff --git a/stregsystem/products/migrations/0001_initial.py b/stregsystem/products/migrations/0001_initial.py new file mode 100644 index 0000000..2935e9e --- /dev/null +++ b/stregsystem/products/migrations/0001_initial.py @@ -0,0 +1,67 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Listing', + fields=[ + ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True, serialize=False)), + ('_name', models.CharField(verbose_name='name', blank=True, null=True, max_length=64)), + ('number', models.IntegerField()), + ('price', models.IntegerField()), + ], + options={ + }, + bases=(models.Model,), + ), + migrations.CreateModel( + name='PointOfSale', + fields=[ + ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True, serialize=False)), + ('name', models.CharField(max_length=64)), + ('listings', models.ManyToManyField(to='products.Listing')), + ], + options={ + }, + bases=(models.Model,), + ), + migrations.CreateModel( + name='Product', + fields=[ + ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True, serialize=False)), + ('name', models.CharField(max_length=64)), + ], + options={ + }, + bases=(models.Model,), + ), + migrations.CreateModel( + name='Tag', + fields=[ + ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True, serialize=False)), + ('name', models.CharField(max_length=64)), + ('value', models.IntegerField(blank=True, null=True)), + ], + options={ + }, + bases=(models.Model,), + ), + migrations.AlterUniqueTogether( + name='tag', + unique_together=set([('name', 'value')]), + ), + migrations.AddField( + model_name='listing', + name='product', + field=models.ForeignKey(to='products.Product'), + preserve_default=True, + ), + ] diff --git a/stregsystem/products/migrations/__init__.py b/stregsystem/products/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/stregsystem/products/models.py b/stregsystem/products/models.py new file mode 100644 index 0000000..22e288d --- /dev/null +++ b/stregsystem/products/models.py @@ -0,0 +1,54 @@ +from django.db import models +from django.utils import html + + +class Product(models.Model): + name = models.CharField(max_length=64) + + def __str__(self): + return self.name + + +class PointOfSale(models.Model): + name = models.CharField(max_length=64) + listings = models.ManyToManyField('Listing') + + def __str__(self): + return self.name + + +class Listing(models.Model): + _name = models.CharField(verbose_name="name", + max_length=64, + null=True, + blank=True) + number = models.IntegerField() + price = models.IntegerField() + product = models.ForeignKey('Product') + + @property + def name(self): + if self._name: + return self._name + else: + return self.product.name + + @name.setter + def name(self, n): + self._name = n + + def __str__(self): + name = html.strip_tags(self.name) + return str.format("{name} #{s.number} ({s.price})", name=name, s=self) + + +class Tag(models.Model): + name = models.CharField(max_length=64) + value = models.IntegerField(null=True, blank=True) + + def __str__(self): + return self.name + + class Meta: + # should ensure that we get no tag dupes + unique_together = ("name", "value") diff --git a/stregsystem/stregsystem/migrations/__init__.py b/stregsystem/stregsystem/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/stregsystem/stregsystem/settings/base.py b/stregsystem/stregsystem/settings/base.py index 5417b30..5bb3303 100644 --- a/stregsystem/stregsystem/settings/base.py +++ b/stregsystem/stregsystem/settings/base.py @@ -38,7 +38,13 @@ THIRD_PARTY_APPS = () -PROJECT_APPS = () +PROJECT_APPS = ( + 'stregsystem', + 'fembers', + 'products', + 'transactions', + +) INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + PROJECT_APPS diff --git a/stregsystem/stregsystem/test/__init__.py b/stregsystem/stregsystem/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/stregsystem/test-fixture.json b/stregsystem/test-fixture.json new file mode 100644 index 0000000..d01c9be --- /dev/null +++ b/stregsystem/test-fixture.json @@ -0,0 +1,144 @@ +[ +{ + "pk": 1, + "fields": { + "_phone_number": "88885555", + "username": "Test", + "name": "Test Chesterson", + "join_date": "2015-03-02T20:59:09.849Z", + "note": "This is test, he is a happy user.", + "email": "test@example.com", + "_pin": "1234", + "active": true, + "number": 1 + }, + "model": "fembers.member" +}, +{ + "pk": 2, + "fields": { + "_phone_number": "", + "username": "undefined", + "name": "Bob Paulson", + "join_date": "2015-03-02T21:02:19.358Z", + "note": "This is Robert Paulson.\r\n\r\nWe can't talk about his organization.", + "email": "fight.club@example.com", + "_pin": "1234", + "active": true, + "number": 2 + }, + "model": "fembers.member" +}, +{ + "pk": 1, + "fields": { + "members": [ + 1, + 2 + ], + "name": "Everyone" + }, + "model": "fembers.list" +}, +{ + "pk": 1, + "fields": { + "product": null, + "value": 9000, + "member": 1, + "name": "" + }, + "model": "transactions.transaction" +}, +{ + "pk": 2, + "fields": { + "product": 2, + "value": -700, + "member": 1, + "name": "" + }, + "model": "transactions.transaction" +}, +{ + "pk": 3, + "fields": { + "product": null, + "value": 0, + "member": null, + "name": "Nothing" + }, + "model": "transactions.transaction" +}, +{ + "pk": 2, + "fields": { + "name": "Limfjordsporter" + }, + "model": "products.product" +}, +{ + "pk": 3, + "fields": { + "name": "