Some things
This commit is contained in:
parent
e7c8965034
commit
aaafe1d0b4
27 changed files with 457 additions and 1 deletions
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "dbsettings"]
|
||||
path = dbsettings
|
||||
url = git@kumig.it:kumisystems/dbsettings.git
|
0
auction/__init__.py
Normal file
0
auction/__init__.py
Normal file
10
auction/admin.py
Normal file
10
auction/admin.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from auction.models import Inquiry, Profile, PartnerProfile, ClientProfile
|
||||
|
||||
# Register your models here.
|
||||
|
||||
admin.site.register(Inquiry)
|
||||
admin.site.register(Profile)
|
||||
admin.site.register(PartnerProfile)
|
||||
admin.site.register(ClientProfile)
|
5
auction/apps.py
Normal file
5
auction/apps.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
class AuctionConfig(AppConfig):
|
||||
name = 'auction'
|
||||
|
25
auction/migrations/0001_initial.py
Normal file
25
auction/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
# Generated by Django 2.2.6 on 2019-12-22 21:20
|
||||
|
||||
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='Inquiry',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('amount', models.DecimalField(decimal_places=2, max_digits=25)),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
]
|
30
auction/migrations/0002_clientprofile_partnerprofile.py
Normal file
30
auction/migrations/0002_clientprofile_partnerprofile.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
# Generated by Django 2.2.6 on 2019-12-22 22:05
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('auction', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='PartnerProfile',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='ClientProfile',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
]
|
87
auction/migrations/0003_auto_20191222_2310.py
Normal file
87
auction/migrations/0003_auto_20191222_2310.py
Normal file
|
@ -0,0 +1,87 @@
|
|||
# Generated by Django 2.2.6 on 2019-12-22 23:10
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import django_countries.fields
|
||||
import phonenumber_field.modelfields
|
||||
import vies.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('contenttypes', '0002_remove_content_type_name'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('auction', '0002_clientprofile_partnerprofile'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='clientprofile',
|
||||
options={'base_manager_name': 'objects'},
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='partnerprofile',
|
||||
options={'base_manager_name': 'objects'},
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='clientprofile',
|
||||
name='id',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='clientprofile',
|
||||
name='user',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='partnerprofile',
|
||||
name='id',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='partnerprofile',
|
||||
name='user',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='partnerprofile',
|
||||
name='company',
|
||||
field=models.CharField(default=None, max_length=128),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='partnerprofile',
|
||||
name='vatid',
|
||||
field=vies.models.VATINField(blank=True, max_length=14, null=True),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Profile',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('first_name', models.CharField(max_length=128)),
|
||||
('last_name', models.CharField(max_length=128)),
|
||||
('address', models.CharField(max_length=128)),
|
||||
('address2', models.CharField(max_length=128)),
|
||||
('zipcode', models.CharField(max_length=15)),
|
||||
('city', models.CharField(max_length=128)),
|
||||
('country', django_countries.fields.CountryField(max_length=2)),
|
||||
('phone', phonenumber_field.modelfields.PhoneNumberField(max_length=128, region=None)),
|
||||
('polymorphic_ctype', models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_auction.profile_set+', to='contenttypes.ContentType')),
|
||||
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
'base_manager_name': 'objects',
|
||||
},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='clientprofile',
|
||||
name='profile_ptr',
|
||||
field=models.OneToOneField(auto_created=True, default=None, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='auction.Profile'),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='partnerprofile',
|
||||
name='profile_ptr',
|
||||
field=models.OneToOneField(auto_created=True, default=None, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='auction.Profile'),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
19
auction/migrations/0004_auto_20191222_2318.py
Normal file
19
auction/migrations/0004_auto_20191222_2318.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Generated by Django 2.2.6 on 2019-12-22 23:18
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('auction', '0003_auto_20191222_2310'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='inquiry',
|
||||
name='user',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='auction.ClientProfile'),
|
||||
),
|
||||
]
|
0
auction/migrations/__init__.py
Normal file
0
auction/migrations/__init__.py
Normal file
49
auction/models.py
Normal file
49
auction/models.py
Normal file
|
@ -0,0 +1,49 @@
|
|||
from django.db.models import Model, CharField, ForeignKey, DecimalField, OneToOneField, CASCADE
|
||||
from django.contrib.auth.models import User
|
||||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
|
||||
from django_countries.fields import CountryField
|
||||
from polymorphic.models import PolymorphicModel
|
||||
from phonenumber_field.modelfields import PhoneNumberField
|
||||
from vies.models import VATINField
|
||||
|
||||
class Profile(PolymorphicModel):
|
||||
user = OneToOneField(User, on_delete=CASCADE)
|
||||
first_name = CharField(max_length=128)
|
||||
last_name = CharField(max_length=128)
|
||||
address = CharField(max_length=128)
|
||||
address2 = CharField(max_length=128)
|
||||
zipcode = CharField(max_length=15)
|
||||
city = CharField(max_length=128)
|
||||
country = CountryField()
|
||||
phone = PhoneNumberField()
|
||||
|
||||
class ClientProfile(Profile):
|
||||
pass
|
||||
|
||||
class PartnerProfile(Profile):
|
||||
company = CharField(max_length=128)
|
||||
vatid = VATINField(blank=True, null=True)
|
||||
|
||||
def create_client_profile(user):
|
||||
ClientProfile.objects.create(user=user)
|
||||
|
||||
def create_partner_profile(user):
|
||||
PartnerProfile.objects.create(user=user)
|
||||
|
||||
@receiver(post_save, sender=User)
|
||||
def save_user_profile(sender, instance, **kwargs):
|
||||
try:
|
||||
instance.partnerprofile.save()
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
instance.partnerprofile.save()
|
||||
except:
|
||||
pass
|
||||
|
||||
class Inquiry(Model):
|
||||
user = ForeignKey(ClientProfile, on_delete=CASCADE)
|
||||
amount = DecimalField(max_digits=25, decimal_places=2)
|
3
auction/tests.py
Normal file
3
auction/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
3
auction/views.py
Normal file
3
auction/views.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
1
dbsettings
Submodule
1
dbsettings
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit ce4c2400431152e04b8ff0f23704c41a7087c14d
|
3
packages.txt
Normal file
3
packages.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
libssl-dev
|
||||
libffi-dev
|
||||
libreoffice
|
0
payment/__init__.py
Normal file
0
payment/__init__.py
Normal file
7
payment/admin.py
Normal file
7
payment/admin.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from django.contrib import admin
|
||||
from payment.models import Payment, KlarnaPayment
|
||||
|
||||
# Register your models here.
|
||||
|
||||
admin.site.register(Payment)
|
||||
admin.site.register(KlarnaPayment)
|
5
payment/apps.py
Normal file
5
payment/apps.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class PaymentConfig(AppConfig):
|
||||
name = 'payment'
|
20
payment/migrations/0001_initial.py
Normal file
20
payment/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Generated by Django 2.2.6 on 2019-12-22 18:46
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Payment',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
],
|
||||
),
|
||||
]
|
71
payment/migrations/0002_auto_20191222_2018.py
Normal file
71
payment/migrations/0002_auto_20191222_2018.py
Normal file
|
@ -0,0 +1,71 @@
|
|||
# Generated by Django 2.2.6 on 2019-12-22 20:18
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('contenttypes', '0002_remove_content_type_name'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('payment', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='PaypalPayment',
|
||||
fields=[
|
||||
('payment_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='payment.Payment')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
'base_manager_name': 'objects',
|
||||
},
|
||||
bases=('payment.payment',),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='SofortPayment',
|
||||
fields=[
|
||||
('payment_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='payment.Payment')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
'base_manager_name': 'objects',
|
||||
},
|
||||
bases=('payment.payment',),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='StripePayment',
|
||||
fields=[
|
||||
('payment_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='payment.Payment')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
'base_manager_name': 'objects',
|
||||
},
|
||||
bases=('payment.payment',),
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='payment',
|
||||
options={'base_manager_name': 'objects'},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='payment',
|
||||
name='amount',
|
||||
field=models.DecimalField(decimal_places=2, default=0, max_digits=10),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='payment',
|
||||
name='polymorphic_ctype',
|
||||
field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_payment.payment_set+', to='contenttypes.ContentType'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='payment',
|
||||
name='user',
|
||||
field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
20
payment/migrations/0003_auto_20191222_2048.py
Normal file
20
payment/migrations/0003_auto_20191222_2048.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Generated by Django 2.2.6 on 2019-12-22 20:48
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('contenttypes', '0002_remove_content_type_name'),
|
||||
('payment', '0002_auto_20191222_2018'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameModel(
|
||||
old_name='SofortPayment',
|
||||
new_name='KlarnaPayment',
|
||||
),
|
||||
]
|
29
payment/migrations/0004_auto_20191222_2120.py
Normal file
29
payment/migrations/0004_auto_20191222_2120.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
# Generated by Django 2.2.6 on 2019-12-22 21:20
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('auction', '0001_initial'),
|
||||
('payment', '0003_auto_20191222_2048'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='payment',
|
||||
name='amount',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='payment',
|
||||
name='user',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='payment',
|
||||
name='inquiry',
|
||||
field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, to='auction.Inquiry'),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
0
payment/migrations/__init__.py
Normal file
0
payment/migrations/__init__.py
Normal file
46
payment/models.py
Normal file
46
payment/models.py
Normal file
|
@ -0,0 +1,46 @@
|
|||
from django.db.models import Model, ForeignKey, DecimalField, CASCADE
|
||||
from django.conf import settings
|
||||
from polymorphic.models import PolymorphicModel
|
||||
|
||||
from auction.models import Inquiry
|
||||
|
||||
# Create your models here.
|
||||
|
||||
class Payment(PolymorphicModel):
|
||||
inquiry = ForeignKey(Inquiry, on_delete=CASCADE)
|
||||
|
||||
def status(self):
|
||||
raise NotImplementedError("status() not implemented in %s!" % type(self).__name__)
|
||||
|
||||
class PaypalPayment(Payment):
|
||||
pass
|
||||
|
||||
class StripePayment(Payment):
|
||||
pass
|
||||
|
||||
class KlarnaPayment(Payment):
|
||||
def create(self):
|
||||
lang = settings.LANGUAGE_CODE
|
||||
|
||||
json = ("""
|
||||
{
|
||||
"purchase_country": "AT",
|
||||
"purchase_currency": "EUR",
|
||||
"locale": "%s",
|
||||
"order_amount": 10,
|
||||
"order_tax_amount": 0,
|
||||
"order_lines": [{
|
||||
"type": "digital",
|
||||
"reference": "19-402",
|
||||
"name": "Battery Power Pack",
|
||||
"quantity": 1,
|
||||
"unit_price": 10,
|
||||
"tax_rate": 0,
|
||||
"total_amount": 10,
|
||||
"total_discount_amount": 0,
|
||||
"total_tax_amount": 0,
|
||||
"image_url": "https://www.exampleobjects.com/logo.png",
|
||||
"product_url": "https://www.estore.com/products/f2a8d7e34"
|
||||
}]
|
||||
}""".strip() % (lang))
|
||||
|
3
payment/tests.py
Normal file
3
payment/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
3
payment/views.py
Normal file
3
payment/views.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
8
requirements.txt
Normal file
8
requirements.txt
Normal file
|
@ -0,0 +1,8 @@
|
|||
paypalrestsdk
|
||||
django-polymorphic
|
||||
django-vies
|
||||
pdfdocument
|
||||
django-countries
|
||||
django-phonenumber-field
|
||||
phonenumbers
|
||||
odfpy
|
|
@ -37,6 +37,11 @@ INSTALLED_APPS = [
|
|||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'payment',
|
||||
'dbsettings',
|
||||
'auction',
|
||||
'django_countries',
|
||||
'phonenumber_field',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
@ -103,7 +108,7 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/2.2/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
LANGUAGE_CODE = 'de-at'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
|
||||
|
@ -118,3 +123,4 @@ USE_TZ = True
|
|||
# https://docs.djangoproject.com/en/2.2/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
|
||||
|
|
Loading…
Reference in a new issue