mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 15:51:19 +00:00
Shopping list structure view addition
This commit is contained in:
parent
9d8264bcbb
commit
5b2f126eee
@ -7,6 +7,7 @@
|
||||
{% block content %}
|
||||
{% if current_tab == "stocks" %}
|
||||
<p><a href="{{ url('stock:new_item', stock_id=stock.id)}}">{% trans %}New item{% endtrans %}</a></p>
|
||||
<h5><a href="{{ url('stock:shopping_list', stock_id=stock.id)}}">{% trans %}Shopping list{% endtrans %}</a></h5>
|
||||
{% endif %}
|
||||
{% if stock %}
|
||||
<h3>{{ stock }}</h3>
|
||||
|
@ -11,7 +11,7 @@
|
||||
{% for s in stock_list.order_by('name') %}
|
||||
<li>
|
||||
{% if user.can_edit(s) %}
|
||||
<a href="{{ url('stock:items_list', stock_id=s.id)}}">{{s}}</a>
|
||||
<a href="{{ url('stock:items_list', stock_id=s.id) }}">{{s}}</a>
|
||||
- <a href="{{ url('stock:edit', stock_id=s.id) }}">Edit</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
|
10
stock/templates/stock/stock_shopping_list.jinja
Normal file
10
stock/templates/stock/stock_shopping_list.jinja
Normal file
@ -0,0 +1,10 @@
|
||||
{% extends "core/base.jinja" %}
|
||||
|
||||
{% block title %}
|
||||
Shopping list for {{ stock }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h3>Shopping list for {{ stock }}</h3>
|
||||
|
||||
{% endblock %}
|
@ -12,5 +12,5 @@ urlpatterns = [
|
||||
url(r'^(?P<stock_id>[0-9]+)$', StockItemList.as_view(), name='items_list'),
|
||||
url(r'^(?P<stock_id>[0-9]+)/stockItem/newItem$', StockItemCreateView.as_view(), name='new_item'),
|
||||
url(r'^stockItem/(?P<item_id>[0-9]+)/edit$', StockItemEditView.as_view(), name='edit_item'),
|
||||
|
||||
url(r'^(?P<stock_id>[0-9]+)/shopping$', StockShoppingListView.as_view(), name='shopping_list'),
|
||||
]
|
||||
|
@ -13,7 +13,7 @@ from stock.models import Stock, StockItem
|
||||
|
||||
|
||||
|
||||
class StockMain(CounterAdminTabsMixin, CanCreateMixin, DetailView):
|
||||
class StockItemList(CounterAdminTabsMixin, CanCreateMixin, ListView):
|
||||
"""
|
||||
The stockitems list view for the counter owner
|
||||
"""
|
||||
@ -22,12 +22,6 @@ class StockMain(CounterAdminTabsMixin, CanCreateMixin, DetailView):
|
||||
pk_url_kwarg = "stock_id"
|
||||
current_tab = "stocks"
|
||||
|
||||
#def get_context_data(self, **kwargs):
|
||||
# context = super(StockItemList, self).get_context_data(**kwargs)
|
||||
# if 'stock' in self.request.GET.keys():
|
||||
# context['stock'] = Stock.objects.filter(id=self.request.GET['stock']).first()
|
||||
# return context
|
||||
|
||||
class StockListView(CounterAdminTabsMixin, CanViewMixin, ListView):
|
||||
"""
|
||||
A list view for the admins
|
||||
@ -94,8 +88,7 @@ class StockCreateView(CounterAdminTabsMixin, CanCreateMixin, CreateView):
|
||||
class StockItemCreateView(CounterAdminTabsMixin, CanCreateMixin, CreateView):
|
||||
"""
|
||||
A create view for a new StockItem
|
||||
"""
|
||||
|
||||
"""
|
||||
model = StockItem
|
||||
form_class = modelform_factory(StockItem, fields=['name', 'unit_quantity', 'effective_quantity', 'type', 'stock_owner'])
|
||||
template_name = 'core/create.jinja'
|
||||
@ -109,6 +102,20 @@ class StockItemCreateView(CounterAdminTabsMixin, CanCreateMixin, CreateView):
|
||||
return ret
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse_lazy('stock:items_list', kwargs={'stock_id':self.object.stock_owner.id}) + '?stock=' + str(self.object.stock_owner.id)
|
||||
return reverse_lazy('stock:items_list', kwargs={'stock_id':self.object.stock_owner.id})
|
||||
|
||||
|
||||
|
||||
class StockShoppingListView(CounterAdminTabsMixin, CanViewMixin, ListView):
|
||||
"""
|
||||
A list view for the people to know the item to buy
|
||||
"""
|
||||
model = Stock
|
||||
template_name = "stock/stock_shopping_list.jinja"
|
||||
pk_url_kwarg = "stock_id"
|
||||
current_tab = "stocks"
|
||||
|
||||
def get_context_data(self):
|
||||
ret = super(StockShoppingListView, self).get_context_data()
|
||||
if 'stock_id' in self.kwargs.keys():
|
||||
ret['stock'] = Stock.objects.filter(id=self.kwargs['stock_id']).first();
|
||||
return ret
|
||||
|
Loading…
Reference in New Issue
Block a user