Add Payment and Refund models and admin
This commit is contained in:
parent
e0e968b3d0
commit
0d44b6c7af
9 changed files with 114 additions and 0 deletions
0
refunding/__init__.py
Normal file
0
refunding/__init__.py
Normal file
18
refunding/admin.py
Normal file
18
refunding/admin.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
from refunding.models import Refund, Payment
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(Refund)
|
||||||
|
class RefundAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ('title', 'date', 'user')
|
||||||
|
list_display_links = ('title',)
|
||||||
|
search_fields = ('title',)
|
||||||
|
date_hierarchy = 'date'
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(Payment)
|
||||||
|
class PaymentAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ('title', 'date', 'value', 'user', 'refund')
|
||||||
|
list_display_links = ('title',)
|
||||||
|
search_fields = ('title',)
|
||||||
|
date_hierarchy = 'date'
|
5
refunding/apps.py
Normal file
5
refunding/apps.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class RefundingConfig(AppConfig):
|
||||||
|
name = 'refunding'
|
51
refunding/migrations/0001_initial.py
Normal file
51
refunding/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.9.6 on 2016-06-03 18:18
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Payment',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('title', models.CharField(max_length=100)),
|
||||||
|
('date', models.DateField()),
|
||||||
|
('value', models.IntegerField()),
|
||||||
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('updated_at', models.DateTimeField(auto_now=True)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Refund',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('title', models.CharField(max_length=100)),
|
||||||
|
('date', models.DateField()),
|
||||||
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('updated_at', models.DateTimeField(auto_now=True)),
|
||||||
|
('user', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='payment',
|
||||||
|
name='refund',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='refunding.Refund'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='payment',
|
||||||
|
name='user',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL),
|
||||||
|
),
|
||||||
|
]
|
0
refunding/migrations/__init__.py
Normal file
0
refunding/migrations/__init__.py
Normal file
33
refunding/models.py
Normal file
33
refunding/models.py
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
from django.db import models
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
AUTH_USER_MODEL = getattr(settings, 'AUTH_USER_MODEL', 'auth.User')
|
||||||
|
|
||||||
|
|
||||||
|
class Refund(models.Model):
|
||||||
|
title = models.CharField(max_length=100)
|
||||||
|
date = models.DateField()
|
||||||
|
created_at = models.DateTimeField(auto_now_add=True)
|
||||||
|
updated_at = models.DateTimeField(auto_now=True)
|
||||||
|
user = models.ForeignKey(
|
||||||
|
AUTH_USER_MODEL,
|
||||||
|
on_delete=models.PROTECT
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class Payment(models.Model):
|
||||||
|
title = models.CharField(max_length=100)
|
||||||
|
date = models.DateField()
|
||||||
|
value = models.IntegerField()
|
||||||
|
created_at = models.DateTimeField(auto_now_add=True)
|
||||||
|
updated_at = models.DateTimeField(auto_now=True)
|
||||||
|
user = models.ForeignKey(
|
||||||
|
AUTH_USER_MODEL,
|
||||||
|
on_delete=models.PROTECT
|
||||||
|
)
|
||||||
|
refund = models.ForeignKey(
|
||||||
|
Refund,
|
||||||
|
on_delete=models.SET_NULL,
|
||||||
|
null=True,
|
||||||
|
blank=True
|
||||||
|
)
|
3
refunding/tests.py
Normal file
3
refunding/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
3
refunding/views.py
Normal file
3
refunding/views.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
# Create your views here.
|
|
@ -48,6 +48,7 @@ X_FRAME_OPTIONS = 'DENY'
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
|
'refunding',
|
||||||
'authentication',
|
'authentication',
|
||||||
'crispy_forms',
|
'crispy_forms',
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
|
|
Loading…
Reference in a new issue