Skip to content

Commit

Permalink
prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
ralph william mujar authored and ralph william mujar committed Aug 31, 2019
1 parent f32bb1b commit abca343
Show file tree
Hide file tree
Showing 164 changed files with 11,616 additions and 55 deletions.
13 changes: 13 additions & 0 deletions customers/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,20 @@ class Meta:
widgets = {'size': forms.Select(choices=size_choices)}

class OrderForm(forms.ModelForm):

payment_choices = [ ('0', 'Not yet paid'),
('1', 'Partially paid'),
('2', 'Fully paid')]

payment_status = forms.ChoiceField(choices = payment_choices)

class Meta:
model = Order
fields = '__all__'
widgets = {
'item' : forms.Select(attrs={'id' : 'item' }),
'qty' : forms.TextInput(attrs={'id' : 'qty' }),
'shipping_fee' : forms.TextInput(attrs={'id' : 'shipping_fee' }),
'total_price' : forms.TextInput(attrs={'id' : 'total_price' }),
}

18 changes: 18 additions & 0 deletions customers/migrations/0006_auto_20190831_0941.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.3 on 2019-08-31 09:41

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('customers', '0005_item_date_encoded'),
]

operations = [
migrations.RenameField(
model_name='order',
old_name='price',
new_name='total_price',
),
]
18 changes: 18 additions & 0 deletions customers/migrations/0007_auto_20190831_0955.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.3 on 2019-08-31 09:55

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('customers', '0006_auto_20190831_0941'),
]

operations = [
migrations.AlterField(
model_name='order',
name='total_price',
field=models.DecimalField(decimal_places=2, max_digits=7),
),
]
27 changes: 27 additions & 0 deletions customers/migrations/0008_auto_20190831_1256.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 2.2.3 on 2019-08-31 12:56

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('customers', '0007_auto_20190831_0955'),
]

operations = [
migrations.RemoveField(
model_name='order',
name='status',
),
migrations.AddField(
model_name='order',
name='payment_status',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='order',
name='ship_status',
field=models.IntegerField(default=0),
),
]
28 changes: 28 additions & 0 deletions customers/migrations/0009_auto_20190831_1324.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 2.2.3 on 2019-08-31 13:24

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('customers', '0008_auto_20190831_1256'),
]

operations = [
migrations.RenameField(
model_name='order',
old_name='ship_status',
new_name='shipping_fee',
),
migrations.AddField(
model_name='order',
name='notes',
field=models.TextField(default='None'),
),
migrations.AddField(
model_name='order',
name='shipping_status',
field=models.BooleanField(default=True),
),
]
23 changes: 23 additions & 0 deletions customers/migrations/0010_auto_20190831_1516.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 2.2.3 on 2019-08-31 15:16

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('customers', '0009_auto_20190831_1324'),
]

operations = [
migrations.AlterField(
model_name='order',
name='shipping_fee',
field=models.DecimalField(decimal_places=2, max_digits=7),
),
migrations.AlterField(
model_name='order',
name='shipping_status',
field=models.BooleanField(default=False),
),
]
21 changes: 17 additions & 4 deletions customers/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Customer(models.Model):
date_encoded = models.DateTimeField(auto_now_add = True)

def __str__(self):
return self.first_name
return self.first_name.title() +" "+ self.last_name.title()

class Item(models.Model):

Expand All @@ -20,16 +20,29 @@ class Item(models.Model):
date_encoded = models.DateTimeField(auto_now_add = True)

def __str__(self):
return self.name +" "+ self.size
return self.name.title() +" "+ self.size.upper() +" (price : "+str(self.price)+")"

class Order(models.Model):

customer = models.ForeignKey(Customer, on_delete=models.CASCADE)
item = models.ForeignKey(Item, on_delete=models.CASCADE)
qty = models.IntegerField(default=0)
price = models.FloatField(default=0)
status = models.CharField(max_length=75, default='on process')
shipping_fee = models.DecimalField(max_digits=7, decimal_places=2)
total_price = models.DecimalField(max_digits=7, decimal_places=2)

payment_status = models.IntegerField(default=0)
shipping_status = models.BooleanField(default=False)

notes = models.TextField(default="None")
date = models.DateTimeField(auto_now_add = True)

def __str__(self):
return self.item.name
#
# def compute_total_price(self):
# self.total_price = (self.item.price * self.qty)
# return self.total_price
#
# def save(self, *args, **kwargs):
# self.total_price = self.compute_total_price()
# super(Order, self).save(*args, **kwargs)
Binary file not shown.
Loading

0 comments on commit abca343

Please sign in to comment.