Commit 33c7e7db authored by Lo-J's avatar Lo-J

addition of Stock app, model, templates, urls

parent fdfd7e73
......@@ -59,6 +59,7 @@ INSTALLED_APPS = (
'sas',
'com',
'election',
'stock',
)
MIDDLEWARE_CLASSES = (
......
from django.contrib import admin
from stock.models import Stock, StockItem
# Register your models here.
admin.site.register(Stock)
admin.site.register(StockItem)
\ No newline at end of file
# -*- 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')),
],
),
]
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):
""" The Stock class, this one is used to know how many products are left for a specific counter """
name = models.CharField(_('name'), max_length=64)
counter = models.OneToOneField(Counter, verbose_name=_('counter'), related_name='stock')
def __str__(self):
return self.name
return "%s (%s)" % (self.name, self.counter)
class StockItem(models.Model):
""" The StockItem class, element of the stock """
......@@ -17,5 +19,5 @@ class StockItem(models.Model):
stock_owner = models.ForeignKey(Stock, related_name="stock_owner")
def __str__(self):
return self.name
return "%s (%s)" % (self.name, self.stock_owner)
TOTO
\ No newline at end of file
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'),
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment