forked from f-klubben/nottherealstregsystem
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The three new apps, fembers, products, and transactions were added in this commit. Introducing the initial design and a fixture for populating some example data. The models should be straight forward.
- Loading branch information
Showing
20 changed files
with
437 additions
and
1 deletion.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": "[email protected]", | ||
"_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": "[email protected]", | ||
"_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": "<h1>Fad\u00f8l (Tuborg/Classic)</h1>" | ||
}, | ||
"model": "products.product" | ||
}, | ||
{ | ||
"pk": 4, | ||
"fields": { | ||
"name": "<h1> Fad\u00f8l i personligt glas (Tuborg/Classic) </h1>" | ||
}, | ||
"model": "products.product" | ||
}, | ||
{ | ||
"pk": 2, | ||
"fields": { | ||
"listings": [ | ||
1, | ||
2, | ||
3 | ||
], | ||
"name": "Foobar" | ||
}, | ||
"model": "products.pointofsale" | ||
}, | ||
{ | ||
"pk": 1, | ||
"fields": { | ||
"product": 2, | ||
"price": 700, | ||
"number": 14, | ||
"_name": "" | ||
}, | ||
"model": "products.listing" | ||
}, | ||
{ | ||
"pk": 2, | ||
"fields": { | ||
"product": 3, | ||
"price": 2100, | ||
"number": 65, | ||
"_name": "" | ||
}, | ||
"model": "products.listing" | ||
}, | ||
{ | ||
"pk": 3, | ||
"fields": { | ||
"product": 4, | ||
"price": 2500, | ||
"number": 1765, | ||
"_name": "" | ||
}, | ||
"model": "products.listing" | ||
}, | ||
{ | ||
"pk": 1, | ||
"fields": { | ||
"value": null, | ||
"name": "\u00d8l" | ||
}, | ||
"model": "products.tag" | ||
} | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.contrib import admin | ||
|
||
from transactions.models import Transaction | ||
|
||
admin.site.register(Transaction) |
Oops, something went wrong.