Skip to content

Commit

Permalink
Reorganization
Browse files Browse the repository at this point in the history
Because the app should have more independence from the project.
  • Loading branch information
Kaezon committed Apr 17, 2016
1 parent 2ef6c31 commit 94833b4
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 2 deletions.
41 changes: 41 additions & 0 deletions rapid_sales_tool/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.3 on 2016-04-17 02:31
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Order',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('customer_name', models.CharField(max_length=64)),
('item_quantity', models.PositiveIntegerField()),
('order_price', models.DecimalField(decimal_places=2, max_digits=17)),
('is_paid', models.BooleanField()),
],
),
migrations.CreateModel(
name='StockItem',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('item_name', models.CharField(max_length=255)),
('item_count', models.PositiveIntegerField()),
('unit_cost', models.DecimalField(decimal_places=2, max_digits=17)),
],
),
migrations.AddField(
model_name='order',
name='item',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='rapid_sales_tool.StockItem'),
),
]
Empty file.
27 changes: 27 additions & 0 deletions rapid_sales_tool/static/rapid_sales_tool/js/orders.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
var orderModal = $('#newOrderModal')
var orderForm = $('#orderForm');
$( document ).ready(
orderForm.submit(function() {
orderModal.find(".modalResponse").first().empty().attr('class','modalResponse');
$.ajax({
type: orderForm.attr('method'),
url: orderForm.attr('action'),
data: orderForm.serialize(),
success: function(data) {
orderModal.modal('hide');
location.reload();
},
error: function(data) {
orderModal.find(".modalResponse").first().empty().append('<a href="#" class="close" data-dismiss="alert">&times;</a>');
orderModal.find(".modalResponse").first().append(data.responseText);
orderModal.find(".modalResponse").first().addClass("alert alert-danger fade in");
}
});
return false;
}),
$(".modal").each( function() {
$(this).on('hidden.bs.modal', function () {
$(this).find(".modalResponse").first().empty().attr('class','modalResponse');
})
})
);
47 changes: 47 additions & 0 deletions rapid_sales_tool/static/rapid_sales_tool/js/stock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
var addItemModal = $('#newItemModal');
var addStockModal = $('#addStockModal')
var itemForm = $('#addItemForm');
var stockForm = $('#addStockForm');
$( document ).ready(
addItemModal.submit(function() {
addItemModal.find(".modalResponse").first().empty().attr('class','modalResponse');
$.ajax({
type: itemForm.attr('method'),
url: itemForm.attr('action'),
data: itemForm.serialize(),
success: function(data) {
addItemModal.modal('hide');
location.reload();
},
error: function(data) {
addItemModal.find(".modalResponse").first().empty().append('<a href="#" class="close" data-dismiss="alert">&times;</a>');
addItemModal.find(".modalResponse").first().append(data.responseText);
addItemModal.find(".modalResponse").first().addClass("alert alert-danger fade in");
}
});
return false;
}),
stockForm.submit(function() {
addStockModal.find(".modalResponse").first().empty().attr('class','modalResponse');
$.ajax({
type: stockForm.attr('method'),
url: stockForm.attr('action'),
data: stockForm.serialize(),
success: function(data) {
addStockModal.modal('hide');
location.reload();
},
error: function(data) {
addStockModal.find(".modalResponse").first().empty().append('<a href="#" class="close" data-dismiss="alert">&times;</a>');
addStockModal.find(".modalResponse").first().append(data.responseText);
addStockModal.find(".modalResponse").first().addClass("alert alert-danger fade in");
}
});
return false;
}),
$(".modal").each( function() {
$(this).on('hidden.bs.modal', function () {
$(this).find(".modalResponse").first().empty().attr('class','modalResponse');
})
})
);
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions rapid_sales_tool/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def order(request):
return HttpResponseRedirect(reverse(order))
else:
addOrderForm = AddOrderForm()
return render(request, 'public/orders.html', {'addOrderForm': addOrderForm, 'orders': orders, 'service_name': settings.SERVICE_NAME}, context_instance=RequestContext(request))
return render(request, 'rapid_sales_tool/orders.html', {'addOrderForm': addOrderForm, 'orders': orders, 'service_name': settings.SERVICE_NAME}, context_instance=RequestContext(request))

def cancelOrder(request):
if request.method == 'POST':
Expand Down Expand Up @@ -68,7 +68,7 @@ def stock(request):
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))
return render(request, 'rapid_sales_tool/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)
Expand Down

0 comments on commit 94833b4

Please sign in to comment.