Merge branch '16-Modify/emailnotification-project' into 'main'
Email Notication Field Closes #16 See merge request dev/yuyu!3
This commit is contained in:
commit
6702c5e590
5 changed files with 62 additions and 5 deletions
|
@ -1,7 +1,7 @@
|
|||
from djmoney.contrib.django_rest_framework import MoneyField
|
||||
from rest_framework import serializers
|
||||
|
||||
from core.models import Invoice
|
||||
from core.models import Invoice, BillingProject
|
||||
from core.component import component
|
||||
|
||||
|
||||
|
@ -54,3 +54,12 @@ class SimpleInvoiceSerializer(serializers.ModelSerializer):
|
|||
model = Invoice
|
||||
fields = ['id', 'start_date', 'end_date', 'state', 'tax', 'subtotal', 'subtotal_currency', 'total',
|
||||
'total_currency']
|
||||
|
||||
|
||||
class BillingProjectSerializer(serializers.ModelSerializer):
|
||||
tenant_id = serializers.CharField(required=False, read_only=True)
|
||||
email_notification = serializers.EmailField(required=False)
|
||||
|
||||
class Meta:
|
||||
model = BillingProject
|
||||
fields = ['tenant_id', 'email_notification']
|
||||
|
|
25
api/views.py
25
api/views.py
|
@ -8,7 +8,7 @@ from rest_framework import viewsets, serializers
|
|||
from rest_framework.decorators import action
|
||||
from rest_framework.response import Response
|
||||
|
||||
from api.serializers import InvoiceSerializer, SimpleInvoiceSerializer
|
||||
from api.serializers import InvoiceSerializer, SimpleInvoiceSerializer, BillingProjectSerializer
|
||||
from core.component import component, labels
|
||||
from core.component.component import INVOICE_COMPONENT_MODEL
|
||||
from core.exception import PriceNotFound
|
||||
|
@ -250,7 +250,28 @@ class AdminOverviewViewSet(viewsets.ViewSet):
|
|||
|
||||
class ProjectOverviewViewSet(viewsets.ViewSet):
|
||||
def list(self, request):
|
||||
return Response({})
|
||||
project = BillingProject.objects.all()
|
||||
serializer = BillingProjectSerializer(project, many=True)
|
||||
|
||||
return Response(serializer.data)
|
||||
|
||||
@action(detail=True, methods=['GET'])
|
||||
def get_tenant(self, request, pk):
|
||||
project = BillingProject.objects.filter(tenant_id=pk).first()
|
||||
serializer = BillingProjectSerializer(project)
|
||||
|
||||
return Response(serializer.data)
|
||||
|
||||
@action(detail=True, methods=['POST'])
|
||||
def update_email(self, request, pk):
|
||||
project = BillingProject.objects.filter(tenant_id=pk).first()
|
||||
serializer = BillingProjectSerializer(project, data=request.data)
|
||||
serializer.is_valid(raise_exception=True)
|
||||
serializer.save()
|
||||
|
||||
return Response({
|
||||
"status": "success"
|
||||
})
|
||||
|
||||
@action(detail=False, methods=['GET'])
|
||||
def total_resource(self, request):
|
||||
|
|
28
core/migrations/0008_auto_20220621_2253.py
Normal file
28
core/migrations/0008_auto_20220621_2253.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Generated by Django 3.2.6 on 2022-06-21 22:53
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0007_invoice_finish_date'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='billingproject',
|
||||
name='email_notification',
|
||||
field=models.EmailField(blank=True, max_length=256, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='flavorprice',
|
||||
name='flavor_id',
|
||||
field=models.CharField(max_length=256, unique=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='volumeprice',
|
||||
name='volume_type_id',
|
||||
field=models.CharField(max_length=256, unique=True),
|
||||
),
|
||||
]
|
|
@ -59,6 +59,7 @@ class ImagePrice(BaseModel, TimestampMixin, PriceMixin):
|
|||
# region Invoicing
|
||||
class BillingProject(BaseModel, TimestampMixin):
|
||||
tenant_id = models.CharField(max_length=256)
|
||||
email_notification = models.EmailField(max_length=256, blank=True, null=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.tenant_id
|
||||
|
|
|
@ -8,7 +8,6 @@ COMPANY_NAME = "company_name"
|
|||
COMPANY_LOGO = "company_logo"
|
||||
COMPANY_ADDRESS = "company_address"
|
||||
EMAIL_ADMIN = "email_admin"
|
||||
EMAIL_NOTIFICATION = "email_notification"
|
||||
|
||||
DEFAULTS = {
|
||||
BILLING_ENABLED: False,
|
||||
|
@ -17,7 +16,6 @@ DEFAULTS = {
|
|||
COMPANY_LOGO: '',
|
||||
COMPANY_ADDRESS: '',
|
||||
EMAIL_ADMIN: '',
|
||||
EMAIL_NOTIFICATION: '',
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue