Skip to content

Commit

Permalink
☀️ updated project
Browse files Browse the repository at this point in the history
  • Loading branch information
marbrb committed Feb 11, 2018
1 parent e150206 commit 644f1a9
Show file tree
Hide file tree
Showing 26 changed files with 3,744 additions and 66 deletions.
35 changes: 26 additions & 9 deletions sales/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,58 @@
from django.contrib.auth.models import Group
from django.contrib.auth.models import User

admin.site.unregister(Group)
admin.site.unregister(User)
admin.site.site_header = 'Administración de Kenosis'

class BaseModelAdmin(admin.ModelAdmin):
def get_readonly_fields(self, request, obj=None):
if request.user.is_superuser:
return self.readonly_fields

return list(set(
[field.name for field in self.opts.local_fields] +
[field.name for field in self.opts.local_many_to_many]
))

@admin.register(Client)
class ClientAdmin(admin.ModelAdmin):
class ClientAdmin(BaseModelAdmin):
list_display = ('name', 'phone_number', 'email', 'document')
search_fields = ('name', 'document')


@admin.register(Employee)
class EmployeeAdmin(admin.ModelAdmin):
class EmployeeAdmin(BaseModelAdmin):
list_display = ('name', 'phone_number', 'document')
search_fields = ('name', 'document')


@admin.register(EstheticHouse)
class EstheticHouseAdmin(BaseModelAdmin):
list_display = ('id','name',)
search_fields = ('name',)


@admin.register(Product)
class ProductAdmin(admin.ModelAdmin):
class ProductAdmin(BaseModelAdmin):
def sold_out(self, instance):
return instance.is_sold_out

sold_out.boolean = True
sold_out.short_description = 'agotado'

list_display = ('code', 'name', 'price', 'amount', 'sold_out',)
list_display = ('code', 'name', 'house', 'price', 'amount', 'sold_out',)
search_fields = ('code', 'name',)
list_filter = ('house',)


@admin.register(Register)
class RegisterAdmin(admin.ModelAdmin):
def has_add_permission(self, request, obj=None):
return False

def has_delete_permission(self, request, obj=None):
return True

search_fields = ('id',)
list_filter = ('date', 'register_type')
list_display = ('id', 'date', 'register_type', 'value', 'description',)
readonly_fields = ('client', 'description', 'register_type', 'product_name')
list_filter = ('date', 'register_type', 'owner')
list_display = ('id', 'owner', 'date', 'register_type', 'value', 'description', 'product_name', 'is_pay_with_card')
readonly_fields = ('client', 'description', 'register_type', 'product_name')
20 changes: 20 additions & 0 deletions sales/migrations/0014_auto_20171126_1425.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2017-11-26 19:25
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('sales', '0013_auto_20171020_0700'),
]

operations = [
migrations.AlterField(
model_name='product',
name='code',
field=models.CharField(max_length=255, primary_key=True, serialize=False, unique=True, verbose_name='código'),
),
]
28 changes: 28 additions & 0 deletions sales/migrations/0015_auto_20171126_1447.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2017-11-26 19:47
from __future__ import unicode_literals

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


class Migration(migrations.Migration):

dependencies = [
('sales', '0014_auto_20171126_1425'),
]

operations = [
migrations.CreateModel(
name='EstheticHouse',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=512, unique=True, verbose_name='nombre')),
],
),
migrations.AddField(
model_name='product',
name='house',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='sales.EstheticHouse', verbose_name='casa estética'),
),
]
19 changes: 19 additions & 0 deletions sales/migrations/0016_auto_20171126_1454.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2017-11-26 19:54
from __future__ import unicode_literals

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('sales', '0015_auto_20171126_1447'),
]

operations = [
migrations.AlterModelOptions(
name='esthetichouse',
options={'ordering': ['name'], 'verbose_name': 'Casa Estética', 'verbose_name_plural': 'Casas Estéticas'},
),
]
Binary file modified sales/migrations/__pycache__/0001_initial.cpython-34.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified sales/migrations/__pycache__/__init__.cpython-34.pyc
Binary file not shown.
26 changes: 25 additions & 1 deletion sales/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@
from .data import EXPENSE_TYPE


class EstheticHouse(models.Model):
name = models.CharField(
verbose_name='nombre',
max_length=512,
unique=True,
)

def __str__(self):
return self.name

class Meta:
ordering = ['name',]
verbose_name = 'Casa Estética'
verbose_name_plural = 'Casas Estéticas'


class Client(models.Model):
name = models.CharField(
max_length=255,
Expand Down Expand Up @@ -43,9 +59,17 @@ class Meta:


class Product(models.Model):
code = models.IntegerField(
code = models.CharField(
primary_key=True,
verbose_name='código',
max_length=255,
unique=True,
)

house = models.ForeignKey(
'EstheticHouse',
verbose_name='casa estética',
null=True,
)

name = models.CharField(
Expand Down
9 changes: 9 additions & 0 deletions sales/static/css/jquery-confirm.min.css

Large diffs are not rendered by default.

Loading

0 comments on commit 644f1a9

Please sign in to comment.