addition of Stock app, model, templates, urls

This commit is contained in:
guillaume-renaud 2016-10-31 08:19:46 +01:00
parent fdfd7e7388
commit 33c7e7db9f
6 changed files with 52 additions and 4 deletions

View File

@ -59,6 +59,7 @@ INSTALLED_APPS = (
'sas', 'sas',
'com', 'com',
'election', 'election',
'stock',
) )
MIDDLEWARE_CLASSES = ( MIDDLEWARE_CLASSES = (

View File

@ -1,3 +1,7 @@
from django.contrib import admin from django.contrib import admin
from stock.models import Stock, StockItem
# Register your models here. # Register your models here.
admin.site.register(Stock)
admin.site.register(StockItem)

View File

@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('counter', '0011_auto_20161004_2039'),
]
operations = [
migrations.CreateModel(
name='Stock',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=64, verbose_name='name')),
('counter', models.OneToOneField(to='counter.Counter', related_name='stock', verbose_name='counter')),
],
),
migrations.CreateModel(
name='StockItem',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=64, verbose_name='name')),
('unit_quantity', models.IntegerField(default=0, verbose_name='unit quantity')),
('effective_quantity', models.IntegerField(default=0, verbose_name='effective quantity')),
('stock_owner', models.ForeignKey(related_name='stock_owner', to='stock.Stock')),
],
),
]

View File

@ -1,5 +1,7 @@
from django.db import models from django.db import models
from django.counter import Counter from django.utils.translation import ugettext_lazy as _
from counter.models import Counter
class Stock(models.Model): class Stock(models.Model):
""" The Stock class, this one is used to know how many products are left for a specific counter """ """ The Stock class, this one is used to know how many products are left for a specific counter """
@ -7,7 +9,7 @@ class Stock(models.Model):
counter = models.OneToOneField(Counter, verbose_name=_('counter'), related_name='stock') counter = models.OneToOneField(Counter, verbose_name=_('counter'), related_name='stock')
def __str__(self): def __str__(self):
return self.name return "%s (%s)" % (self.name, self.counter)
class StockItem(models.Model): class StockItem(models.Model):
""" The StockItem class, element of the stock """ """ The StockItem class, element of the stock """
@ -17,5 +19,5 @@ class StockItem(models.Model):
stock_owner = models.ForeignKey(Stock, related_name="stock_owner") stock_owner = models.ForeignKey(Stock, related_name="stock_owner")
def __str__(self): def __str__(self):
return self.name return "%s (%s)" % (self.name, self.stock_owner)

View File

@ -0,0 +1 @@
TOTO

8
stock/urls.py Normal file
View File

@ -0,0 +1,8 @@
from django.conf.urls import include, url
from stock.views import *
urlpatterns = [
url(r'^(?P<counter_id>[0-9]+)$', StockListView.as_view(), name='stock_list'),
url(r'^(?P<counter_id>[0-9]+)/new$', StockCreateView.as_view(), name='stock_new'),
]