Skip to content

Commit

Permalink
Beginning the merge
Browse files Browse the repository at this point in the history
I've merged the stock and order apps and got the app to run again.
There's probably more problems, but I need to commit for dev night.
  • Loading branch information
Kaezon committed Apr 17, 2016
1 parent d6e896d commit 2ef6c31
Show file tree
Hide file tree
Showing 21 changed files with 68 additions and 147 deletions.
3 changes: 1 addition & 2 deletions EVERoachCoach/settings.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'stock',
'orders',
'rapid_sales_tool',
'portal',
]

Expand Down
11 changes: 2 additions & 9 deletions EVERoachCoach/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,12 @@
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.conf.urls import include, url
from django.contrib import admin
from portal.views import dashboard
from stock.views import stock, editStock, deleteStock
from orders.views import order, paidOrder, cancelOrder

urlpatterns = [
url(r'^$', dashboard, name='dashboard'),
url(r'^orders/cancel/$', cancelOrder, name='cancelOrder'),
url(r'^orders/paid/$', paidOrder, name='paidOrder'),
url(r'^orders/$', order, name='orders'),
url(r'^stock/delete/$', deleteStock, name='deleteStock'),
url(r'^stock/edit/(?P<stock_id>\d+)', editStock, name='editStock'),
url(r'^stock/$', stock, name='stock'),
url(r'^rst/', include('rapid_sales_tool.urls')),
url(r'^admin/', admin.site.urls),
]
29 changes: 0 additions & 29 deletions orders/migrations/0001_initial.py

This file was deleted.

Empty file removed orders/migrations/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion orders/apps.py → rapid_sales_tool/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@


class OrdersConfig(AppConfig):
name = 'orders'
name = 'rapid_sales_tool'
11 changes: 10 additions & 1 deletion orders/forms.py → rapid_sales_tool/forms.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
from django.forms import ModelForm, ModelChoiceField
from django.forms.models import inlineformset_factory
from stock.models import StockItem
from .models import *

class AddItemForm(ModelForm):
class Meta:
model = StockItem
fields = '__all__'

class AddStockForm(ModelForm):
class Meta:
model = StockItem
fields = ['item_count','unit_cost']

class AddOrderForm(ModelForm):
class Meta:
model = Order
Expand Down
6 changes: 5 additions & 1 deletion orders/models.py → rapid_sales_tool/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from __future__ import unicode_literals

from django.db import models
from stock.models import StockItem

class StockItem(models.Model):
item_name = models.CharField(max_length=255)
item_count = models.PositiveIntegerField()
unit_cost = models.DecimalField(max_digits=17, decimal_places=2)

class Order(models.Model):
customer_name = models.CharField(max_length=64)
Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions rapid_sales_tool/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.conf.urls import url
from .views import *

urlpatterns = [
url(r'^orders/cancel/$', cancelOrder, name='cancelOrder'),
url(r'^orders/paid/$', paidOrder, name='paidOrder'),
url(r'^orders/$', order, name='orders'),
url(r'^stock/delete/$', deleteStock, name='deleteStock'),
url(r'^stock/edit/(?P<stock_id>\d+)', editStock, name='editStock'),
url(r'^stock/$', stock, name='stock')
]
38 changes: 38 additions & 0 deletions orders/views.py → rapid_sales_tool/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,43 @@ def paidOrder(request):
order.save()
response.status_code = 200
return response
else:
Http404("Why are you here?")

def stock(request):
items = StockItem.objects.all()
if request.method == 'POST':
form = AddItemForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect(reverse(stock))
else:
addItemForm = AddItemForm()
addStockForm = AddStockForm()
return render(request, 'public/stock.html', {'addItemForm': addItemForm, 'addStockForm': addStockForm, 'items': items, 'service_name': settings.SERVICE_NAME}, context_instance=RequestContext(request))

def editStock(request, stock_id):
stock_item = get_object_or_404(StockItem, pk=stock_id)
item_instance = get_object_or_404(StockItem, pk=stock_id)
if request.method == 'POST':
form = AddStockForm(request.POST, instance=item_instance)
if form.is_valid():
item_count = form.instance.item_count + stock_item.item_count
unit_cost = ((form.instance.item_count * form.instance.unit_cost) + (stock_item.item_count * stock_item.unit_cost)) / item_count
form.instance.item_count = item_count
form.instance.unit_cost = unit_cost
form.save()
return HttpResponseRedirect(reverse(stock))
else:
raise Http404("Stock item does not exist")

def deleteStock(request):
if request.method == 'POST':
response = HttpResponse()
item_id = request.POST['item_id']
stock_item = get_object_or_404(StockItem, pk=item_id)
stock_item.delete()
response.status_code = 200
return response
else:
Http404("Why are you here?")
Empty file removed stock/__init__.py
Empty file.
3 changes: 0 additions & 3 deletions stock/admin.py

This file was deleted.

7 changes: 0 additions & 7 deletions stock/apps.py

This file was deleted.

13 changes: 0 additions & 13 deletions stock/forms.py

This file was deleted.

25 changes: 0 additions & 25 deletions stock/migrations/0001_initial.py

This file was deleted.

Empty file removed stock/migrations/__init__.py
Empty file.
8 changes: 0 additions & 8 deletions stock/models.py

This file was deleted.

3 changes: 0 additions & 3 deletions stock/tests.py

This file was deleted.

45 changes: 0 additions & 45 deletions stock/views.py

This file was deleted.

0 comments on commit 2ef6c31

Please sign in to comment.