Commit 9f1ddd22 authored by Patrick's avatar Patrick

Normalize "import" of models

parent 65526cee
# -*- coding: utf-8
from django.contrib import admin
from repanier.models import BankAccount
from .bankaccount import BankAccountAdmin
from repanier.models.bankaccount import BankAccount
from repanier.admin.bankaccount import BankAccountAdmin
admin.site.register(BankAccount, BankAccountAdmin)
from repanier.models import Configuration
from .configuration import ConfigurationAdmin
from repanier.models.configuration import Configuration
from repanier.admin.configuration import ConfigurationAdmin
admin.site.register(Configuration, ConfigurationAdmin)
from repanier.models import Customer
from .customer import CustomerWithUserDataAdmin
from repanier.models.customer import Customer
from repanier.admin.customer import CustomerWithUserDataAdmin
admin.site.register(Customer, CustomerWithUserDataAdmin)
from repanier.models import Purchase
from .purchase import PurchaseAdmin
from repanier.models.purchase import Purchase
from repanier.admin.purchase import PurchaseAdmin
admin.site.register(Purchase, PurchaseAdmin)
from repanier.models import LUT_ProductionMode, LUT_DeliveryPoint, LUT_DepartmentForCustomer, LUT_PermanenceRole
from .lut import LUTProductionModeAdmin, LUTPermanenceRoleAdmin, LUTDepartmentForCustomerAdmin, LUTDeliveryPointAdmin
from repanier.models.lut import LUT_ProductionMode, LUT_DeliveryPoint, LUT_DepartmentForCustomer, LUT_PermanenceRole
from repanier.admin.lut import LUTProductionModeAdmin, LUTPermanenceRoleAdmin, LUTDepartmentForCustomerAdmin, LUTDeliveryPointAdmin
admin.site.register(LUT_ProductionMode, LUTProductionModeAdmin)
admin.site.register(LUT_PermanenceRole, LUTPermanenceRoleAdmin)
admin.site.register(LUT_DepartmentForCustomer, LUTDepartmentForCustomerAdmin)
admin.site.register(LUT_DeliveryPoint, LUTDeliveryPointAdmin)
from repanier.models import OfferItemClosed
from .offeritem import OfferItemClosedAdmin
from repanier.models.offeritem import OfferItemClosed
from repanier.admin.offeritem import OfferItemClosedAdmin
admin.site.register(OfferItemClosed, OfferItemClosedAdmin)
from repanier.models import OfferItemSend
from .rule_of_3_per_product import OfferItemSendAdmin
from repanier.models.offeritem import OfferItemSend
from repanier.admin.rule_of_3_per_product import OfferItemSendAdmin
admin.site.register(OfferItemSend, OfferItemSendAdmin)
from repanier.models import CustomerSend
from .rule_of_3_per_customer import CustomerSendAdmin
from repanier.models.invoice import CustomerSend
from repanier.admin.rule_of_3_per_customer import CustomerSendAdmin
admin.site.register(CustomerSend, CustomerSendAdmin)
from repanier.models import PermanenceInPreparation
from .permanence_in_preparation import PermanenceInPreparationAdmin
from repanier.models.permanence import PermanenceInPreparation
from repanier.admin.permanence_in_preparation import PermanenceInPreparationAdmin
admin.site.register(PermanenceInPreparation, PermanenceInPreparationAdmin)
from repanier.models import PermanenceDone
from .permanence_done import PermanenceDoneAdmin
from repanier.models.permanence import PermanenceDone
from repanier.admin.permanence_done import PermanenceDoneAdmin
admin.site.register(PermanenceDone, PermanenceDoneAdmin)
from repanier.models import Producer
from .producer import ProducerAdmin
from repanier.models.producer import Producer
from repanier.admin.producer import ProducerAdmin
admin.site.register(Producer, ProducerAdmin)
from repanier.models import Product
from .product import ProductAdmin
from repanier.models.product import Product
from repanier.admin.product import ProductAdmin
admin.site.register(Product, ProductAdmin)
from repanier.models.box import Box
from .box import BoxAdmin
from repanier.admin.box import BoxAdmin
admin.site.register(Box, BoxAdmin)
from repanier.models import Staff
from .staff import StaffWithUserDataAdmin
from repanier.models.staff import Staff
from repanier.admin.staff import StaffWithUserDataAdmin
admin.site.register(Staff, StaffWithUserDataAdmin)
# -*- coding: utf-8
from __future__ import unicode_literals
# Filters in the right sidebar of the change list page of the admin
from django.contrib.admin import SimpleListFilter
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
from repanier.const import *
# Filters in the right sidebar of the change list page of the admin
from django.contrib.admin import SimpleListFilter
from repanier.models import Producer, Product, LUT_DepartmentForCustomer, Customer, CustomerInvoice, ProducerInvoice, \
Permanence, LUT_ProductionMode
from repanier.models.customer import Customer
from repanier.models.invoice import CustomerInvoice, ProducerInvoice
from repanier.models.lut import LUT_DepartmentForCustomer, LUT_ProductionMode
from repanier.models.permanence import Permanence
from repanier.models.producer import Producer, Product
from repanier.tools import sint
......
......@@ -2,10 +2,7 @@
from __future__ import unicode_literals
from django import forms
from django.conf.urls import url
from django.contrib import admin
from django.core import urlresolvers
from django.http import HttpResponseRedirect
from django.utils.translation import ugettext_lazy as _
from easy_select2 import apply_select2
from import_export import resources, fields
......@@ -15,9 +12,12 @@ from import_export.formats.base_formats import XLS
from repanier.admin.admin_filter import BankAccountFilterByStatus
from repanier.const import *
from repanier.fields.RepanierMoneyField import FormMoneyField
from repanier.models import BankAccount, Customer, Producer, ProducerInvoice, CustomerInvoice
from repanier.xlsx.widget import IdWidget, TwoMoneysWidget, ProducerNameWidget, CustomerNameWidget, DateWidgetExcel
from repanier.models.bankaccount import BankAccount
from repanier.models.customer import Customer
from repanier.models.invoice import ProducerInvoice, CustomerInvoice
from repanier.models.producer import Producer
from repanier.xlsx.extended_formats import XLSX_OPENPYXL_1_8_6
from repanier.xlsx.widget import IdWidget, TwoMoneysWidget, ProducerNameWidget, CustomerNameWidget, DateWidgetExcel
class BankAccountResource(resources.ModelResource):
......
......@@ -19,7 +19,7 @@ from parler.forms import TranslatableModelForm
from repanier.admin.fkey_choice_cache_mixin import ForeignKeyCacheMixin
from repanier.const import DECIMAL_ZERO, ORDER_GROUP, INVOICE_GROUP, \
COORDINATION_GROUP, PERMANENCE_OPENED, PERMANENCE_PLANNED, PERMANENCE_CLOSED
COORDINATION_GROUP, PERMANENCE_PLANNED, PERMANENCE_CLOSED
from repanier.models.box import BoxContent, Box
from repanier.models.product import Product
from repanier.models.offeritem import OfferItemWoReceiver
......
......@@ -2,12 +2,14 @@
from __future__ import unicode_literals
from django import forms
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from parler.admin import TranslatableAdmin
from parler.forms import TranslatableModelForm
from repanier.const import COORDINATION_GROUP
from repanier.models import Configuration, Producer
from repanier.models.configuration import Configuration
from repanier.models.producer import Producer
from repanier.tools import send_test_email
......@@ -55,28 +57,29 @@ class ConfigurationDataForm(TranslatableModelForm):
self.add_error(
'send_abstract_order_mail_to_customer',
_('The abstract can only be send if the order is also send to producer'))
email_host_password = self.cleaned_data["email_host_password"]
email_is_custom = self.cleaned_data["email_is_custom"]
if email_is_custom:
# Send test email
if not email_host_password:
email_host_password = self.instance.previous_email_host_password
email_host = self.cleaned_data["email_host"]
email_port = self.cleaned_data["email_port"]
email_use_tls = self.cleaned_data["email_use_tls"]
email_host_user = self.cleaned_data["email_host_user"]
email_send = send_test_email(
host=email_host,
port=email_port,
host_user=email_host_user,
host_password=email_host_password,
use_tls=email_use_tls
)
if not email_send:
self.add_error(
'email_is_custom',
_('Repanier tried to send a test email without success.'))
self.instance.email_is_custom = False
if not settings.DJANGO_SETTINGS_DEMO:
email_is_custom = self.cleaned_data["email_is_custom"]
if email_is_custom:
email_host_password = self.cleaned_data["email_host_password"]
# Send test email
if not email_host_password:
email_host_password = self.instance.previous_email_host_password
email_host = self.cleaned_data["email_host"]
email_port = self.cleaned_data["email_port"]
email_use_tls = self.cleaned_data["email_use_tls"]
email_host_user = self.cleaned_data["email_host_user"]
email_send = send_test_email(
host=email_host,
port=email_port,
host_user=email_host_user,
host_password=email_host_password,
use_tls=email_use_tls
)
if not email_send:
self.add_error(
'email_is_custom',
_('Repanier tried to send a test email without success.'))
self.instance.email_is_custom = False
class Meta:
model = Configuration
......
......@@ -3,9 +3,9 @@ from __future__ import unicode_literals
import uuid
from collections import OrderedDict
from decimal import Decimal
from os import sep as os_sep
from decimal import Decimal
from django import forms
from django.conf import settings
from django.contrib import admin
......@@ -26,10 +26,11 @@ from import_export.widgets import CharWidget
import repanier.apps
from repanier.const import EMPTY_STRING, ORDER_GROUP, INVOICE_GROUP, \
COORDINATION_GROUP, DECIMAL_ONE, TWO_DECIMALS
from repanier.models import Customer, LUT_DeliveryPoint
from repanier.models.customer import Customer
from repanier.models.lut import LUT_DeliveryPoint
from repanier.xlsx.extended_formats import XLSX_OPENPYXL_1_8_6
from repanier.xlsx.widget import IdWidget, OneToOneWidget, \
DecimalBooleanWidget, ZeroDecimalsWidget, TwoMoneysWidget, TranslatedForeignKeyWidget, DateWidgetExcel
from repanier.xlsx.extended_formats import XLSX_OPENPYXL_1_8_6
from repanier.xlsx.xlsx_invoice import export_invoice
......
......@@ -3,7 +3,7 @@ from django.forms.formsets import formset_factory
from django.utils.translation import ugettext_lazy as _
from djangocms_text_ckeditor.widgets import TextEditorWidget
from repanier.models import Producer
from repanier.models.producer import Producer
from repanier.const import REPANIER_MONEY_ZERO
from repanier.fields.RepanierMoneyField import FormMoneyField
......
......@@ -15,7 +15,10 @@ from parler.forms import TranslatableModelForm
from repanier.admin.fkey_choice_cache_mixin import ForeignKeyCacheMixin
from repanier.const import PERMANENCE_CLOSED, ORDER_GROUP, INVOICE_GROUP, \
COORDINATION_GROUP, DECIMAL_ONE, ONE_LEVEL_DEPTH, TWO_LEVEL_DEPTH
from repanier.models import PermanenceBoard, Customer, Permanence, LUT_DeliveryPoint
from repanier.models.customer import Customer
from repanier.models.lut import LUT_DeliveryPoint
from repanier.models.permanence import Permanence
from repanier.models.permanenceboard import PermanenceBoard
class LUTDataForm(TranslatableModelForm):
......
......@@ -10,7 +10,10 @@ from django.utils.translation import ugettext_lazy as _
from repanier.admin.admin_filter import PurchaseFilterByProducerForThisPermanence, \
ProductFilterByDepartmentForThisProducer, OfferItemFilter
from repanier.const import PERMANENCE_CLOSED, PERMANENCE_OPENED, ORDER_GROUP, INVOICE_GROUP, COORDINATION_GROUP
from repanier.models import Permanence, Product, LUT_DepartmentForCustomer, Producer
from repanier.models.lut import LUT_DepartmentForCustomer
from repanier.models.permanence import Permanence
from repanier.models.producer import Producer
from repanier.models.product import Product
from repanier.tools import sint, update_offer_item
......
......@@ -7,10 +7,10 @@ from django.conf.urls import url
from django.contrib import admin
from django.core.checks import messages
from django.db.models import F
from django.shortcuts import render
from django.utils import timezone
from django.http import HttpResponseRedirect, HttpResponse
from django.shortcuts import render
from django.template import Context as TemplateContext, Template
from django.utils import timezone
from django.utils.safestring import mark_safe
from django.utils.text import slugify
from django.utils.translation import ugettext_lazy as _
......@@ -19,10 +19,17 @@ from parler.forms import TranslatableModelForm
import repanier.apps
from repanier.admin.fkey_choice_cache_mixin import ForeignKeyCacheMixin
from repanier.admin.forms import InvoiceOrderForm, ProducerInvoicedFormSet, PermanenceInvoicedForm, ImportXlsxForm, ImportInvoiceForm
from repanier.admin.forms import InvoiceOrderForm, ProducerInvoicedFormSet, PermanenceInvoicedForm, ImportXlsxForm, \
ImportInvoiceForm
from repanier.const import *
from repanier.fields.RepanierMoneyField import RepanierMoney
from repanier.models import Customer, Purchase, PermanenceBoard, LUT_PermanenceRole, BankAccount, PermanenceDone, ProducerInvoice
from repanier.models.bankaccount import BankAccount
from repanier.models.customer import Customer
from repanier.models.invoice import ProducerInvoice
from repanier.models.lut import LUT_PermanenceRole
from repanier.models.permanence import PermanenceDone
from repanier.models.permanenceboard import PermanenceBoard
from repanier.models.purchase import Purchase
from repanier.task import task_invoice
from repanier.tools import send_email_to_who, get_signature
from repanier.xlsx.views import import_xslx_view
......
......@@ -23,8 +23,17 @@ from repanier.admin.fkey_choice_cache_mixin import ForeignKeyCacheMixin
from repanier.admin.forms import OpenAndSendOfferForm, CloseAndSendOrderForm, GeneratePermanenceForm
from repanier.const import *
from repanier.fields.RepanierMoneyField import RepanierMoney
from repanier.models import Customer, Purchase, Producer, PermanenceBoard, LUT_PermanenceRole, PermanenceInPreparation, \
Box, OfferItem, DeliveryBoard, LUT_DeliveryPoint, ProducerInvoice, Product
from repanier.models.customer import Customer
from repanier.models.invoice import ProducerInvoice
from repanier.models.lut import LUT_PermanenceRole, LUT_DeliveryPoint
from repanier.models.permanence import PermanenceInPreparation
from repanier.models.permanenceboard import PermanenceBoard
from repanier.models.purchase import Purchase
from repanier.models.box import Box
from repanier.models.offeritem import OfferItem
from repanier.models.deliveryboard import DeliveryBoard
from repanier.models.product import Product
from repanier.models.producer import Producer
from repanier.task import task_order, task_purchase
from repanier.tools import send_email_to_who, get_signature, get_board_composition
from repanier.xlsx.xlsx_offer import export_offer
......
......@@ -19,16 +19,15 @@ from import_export.widgets import CharWidget
import repanier.apps
from repanier.admin.forms import ImportXlsxForm
from repanier.models import BoxContent
from repanier.const import *
from repanier.models import Permanence, Product, \
Producer
from repanier.tools import producer_web_services_activated, \
update_offer_item
from repanier.xlsx.widget import IdWidget, TwoDecimalsWidget, \
DecimalBooleanWidget, TwoMoneysWidget, DateWidgetExcel
from repanier.models.box import BoxContent
from repanier.models.permanence import Permanence
from repanier.models.producer import Producer
from repanier.tools import producer_web_services_activated
from repanier.xlsx.extended_formats import XLSX_OPENPYXL_1_8_6
from repanier.xlsx.views import import_xslx_view
from repanier.xlsx.widget import IdWidget, TwoDecimalsWidget, \
DecimalBooleanWidget, TwoMoneysWidget, DateWidgetExcel
from repanier.xlsx.xlsx_invoice import export_invoice
from repanier.xlsx.xlsx_product import export_customer_prices
from repanier.xlsx.xlsx_stock import handle_uploaded_stock, export_producer_stock
......
......@@ -23,14 +23,15 @@ from parler.forms import TranslatableModelForm
from repanier.admin.admin_filter import ProductFilterByDepartmentForThisProducer, ProductFilterByProducer, \
ProductFilterByProductioMode, ProductFilterByPlacement, ProductFilterByVatLevel
from repanier.const import *
from repanier.models import Product, \
LUT_ProductionMode, LUT_DepartmentForCustomer, Producer
from repanier.models.lut import LUT_DepartmentForCustomer, LUT_ProductionMode
from repanier.models.producer import Producer
from repanier.models.product import Product
from repanier.task import task_product
from repanier.tools import sint, update_offer_item
from repanier.widget.select_admin_order_unit import SelectAdminOrderUnitWidget
from repanier.xlsx.extended_formats import XLSX_OPENPYXL_1_8_6
from repanier.xlsx.widget import IdWidget, TranslatedForeignKeyWidget, \
DecimalBooleanWidget, ChoiceWidget, ThreeDecimalsWidget, TranslatedManyToManyWidget, TwoMoneysWidget
from repanier.xlsx.extended_formats import XLSX_OPENPYXL_1_8_6
try:
from urllib.parse import parse_qsl
......
......@@ -2,7 +2,6 @@
from __future__ import unicode_literals
from django import forms
from django.conf import settings
from django.conf.urls import url
from django.contrib import admin
from django.core import urlresolvers
......@@ -23,15 +22,19 @@ from repanier.admin.admin_filter import PurchaseFilterByProducerForThisPermanenc
PurchaseFilterByCustomer, PurchaseFilterByPermanence
from repanier.const import *
from repanier.email.email_order import export_order_2_1_customer
from repanier.models import Customer, Purchase, Permanence, Product, \
CustomerInvoice, DeliveryBoard, OfferItem
from repanier.tools import sint, get_or_create_offer_item, get_signature, \
my_order_confirmation_email_send_to
from repanier.models.customer import Customer
from repanier.models.deliveryboard import DeliveryBoard
from repanier.models.invoice import CustomerInvoice
from repanier.models.offeritem import OfferItem
from repanier.models.permanence import Permanence
from repanier.models.product import Product
from repanier.models.purchase import Purchase
from repanier.tools import sint, get_signature
from repanier.widget.select_admin_delivery import SelectAdminDeliveryWidget
from repanier.widget.select_admin_permanence import SelectAdminPermanenceWidget
from repanier.xlsx.extended_formats import XLSX_OPENPYXL_1_8_6
from repanier.xlsx.widget import IdWidget, \
ChoiceWidget, FourDecimalsWidget, TwoMoneysWidget, DateWidgetExcel
from repanier.xlsx.extended_formats import XLSX_OPENPYXL_1_8_6
try:
from urllib.parse import parse_qsl
......@@ -249,7 +252,7 @@ class PurchaseAdmin(ExportMixin, admin.ModelAdmin):
customer, filename, permanence, sender_email,
sender_function, signature)
user_message_level = messages.INFO
user_message = my_order_confirmation_email_send_to(customer)
user_message = customer.my_order_confirmation_email_send_to()
else:
user_message_level = messages.INFO
user_message = _('Order confirmed')
......@@ -493,7 +496,7 @@ class PurchaseAdmin(ExportMixin, admin.ModelAdmin):
else:
# New : product_or_offer_item_id is a product_id
product = Product.objects.filter(id=product_or_offer_item_id).order_by('?').first()
offer_item = get_or_create_offer_item(purchase.permanence, product)
offer_item = product.get_or_create_offer_item(purchase.permanence)
# Select one purchase
previous_purchase = Purchase.objects.filter(
customer=purchase.customer,
......
......@@ -11,8 +11,12 @@ from easy_select2 import Select2
from repanier.admin.fkey_choice_cache_mixin import ForeignKeyCacheMixin
from repanier.const import *
from repanier.fields.RepanierMoneyField import FormMoneyField, RepanierMoney
from repanier.models import Customer, Permanence, Producer, OfferItemSend, Purchase
from repanier.fields.RepanierMoneyField import FormMoneyField
from repanier.models.customer import Customer
from repanier.models.offeritem import OfferItemSend
from repanier.models.permanence import Permanence
from repanier.models.producer import Producer
from repanier.models.purchase import Purchase
from repanier.tools import rule_of_3_reload_purchase
......
......@@ -17,7 +17,11 @@ from repanier.admin.admin_filter import PurchaseFilterByProducerForThisPermanenc
from repanier.admin.fkey_choice_cache_mixin import ForeignKeyCacheMixin
from repanier.const import *
from repanier.fields.RepanierMoneyField import FormMoneyField, RepanierMoney
from repanier.models import Customer, Permanence, Product, LUT_DepartmentForCustomer, Purchase, OfferItem
from repanier.models.customer import Customer
from repanier.models.offeritem import OfferItem
from repanier.models.permanence import Permanence
from repanier.models.product import Product
from repanier.models.purchase import Purchase
from repanier.tools import rule_of_3_reload_purchase
......
......@@ -10,11 +10,12 @@ from django.utils.translation import ugettext_lazy as _
from easy_select2 import apply_select2
from parler.forms import TranslatableModelForm
from .lut import LUTAdmin
from repanier.const import EMPTY_STRING, \
COORDINATION_GROUP, ORDER_GROUP, INVOICE_GROUP, ONE_LEVEL_DEPTH
from repanier.models import Customer, Staff
COORDINATION_GROUP, ONE_LEVEL_DEPTH
from repanier.models.customer import Customer
from repanier.models.staff import Staff
from repanier.views.logout_view import remove_staff_right
from .lut import LUTAdmin
class UserDataForm(TranslatableModelForm):
......
# -*- coding: utf-8
from __future__ import unicode_literals
import sys
import time
import sys
from django.apps import AppConfig
from django.conf import settings
from django.db import connection
from django.db.models import F
from django.utils import translation
from django.utils.translation import ugettext_lazy as _
REPANIER_SETTINGS_CONFIG = None
REPANIER_SETTINGS_TEST_MODE = None
REPANIER_SETTINGS_GROUP_NAME = None
REPANIER_SETTINGS_GROUP_CUSTOMER_ID = None
REPANIER_SETTINGS_GROUP_PRODUCER_ID = None
REPANIER_SETTINGS_PERMANENCE_NAME = _("Permanence")
REPANIER_SETTINGS_PERMANENCES_NAME = _("Permanences")
REPANIER_SETTINGS_PERMANENCE_ON_NAME = _("Permanence on ")
......@@ -69,7 +70,9 @@ class RepanierSettings(AppConfig):
except:
print("waiting for database connection")
time.sleep(1)
from repanier.models import Configuration, LUT_DepartmentForCustomer, Product
from repanier.models.configuration import Configuration
from repanier.models.lut import LUT_DepartmentForCustomer
from repanier.models.product import Product
from repanier.const import DECIMAL_ONE, PERMANENCE_NAME_PERMANENCE, CURRENCY_EUR, ORDER_GROUP, \
INVOICE_GROUP, CONTRIBUTOR_GROUP, COORDINATION_GROUP, WEBMASTER_GROUP
try:
......
......@@ -2,8 +2,10 @@
from django.core.cache import cache
from django.core.management.base import BaseCommand
from menus.menu_pool import menu_pool
from repanier.const import *
from repanier.models import Permanence, OfferItem
from repanier.models.offeritem import OfferItem
from repanier.models.permanence import Permanence
class Command(BaseCommand):
......
......@@ -37,10 +37,10 @@ class Command(BaseCommand):
if result == 0:
email = EmailMultiAlternatives(
"Backup " + db_name,
"Backup of the DB : " + db_name,
settings.DEFAULT_FROM_EMAIL,
[v for k, v in settings.ADMINS]
subject="Backup " + db_name,
body="Backup of the DB : " + db_name,
from_email=settings.DEFAULT_FROM_EMAIL,
to=[v for k, v in settings.ADMINS]
)
email.attach_file(os.path.abspath(backup_file.name),
'application/zip')
......
......@@ -5,7 +5,8 @@ import datetime
from django.core.management.base import BaseCommand
from repanier.const import PERMANENCE_OPENED, DECIMAL_ZERO
from repanier.models import Permanence, CustomerInvoice
from repanier.models.permanence import Permanence
from repanier.models.invoice import CustomerInvoice
from django.conf import settings
from django.utils import translation
......
# -*- coding: utf-8 -*-
from django.core.management.base import BaseCommand
from repanier.const import PERMANENCE_SEND
from repanier.models import Permanence, Purchase, OfferItem, CustomerInvoice, ProducerInvoice, CustomerProducerInvoice, BankAccount
from django.conf import settings
from django.core.management.base import BaseCommand
from django.utils import translation
from repanier.models.permanence import Permanence
from repanier.task.task_purchase import admin_delete
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from string import upper, rsplit
from string import rsplit
from PIL import Image
try:
......@@ -12,8 +14,9 @@ from django.core.files.storage import default_storage
from django.utils.text import slugify
from django.core.management.base import BaseCommand
from django.conf import settings
from repanier.models import LUT_ProductionMode, LUT_DeliveryPoint, LUT_DepartmentForCustomer, LUT_PermanenceRole, \
Product, OfferItem
from repanier.models.lut import LUT_ProductionMode
from repanier.models.product import Product
from repanier.models.offeritem import OfferItem
# sudo rm -rf /var/tmp/django_cache/ptidej.repanier.be/
# cd /home/pi/v2/ptidej/ptidej/media/
......
# -*- coding: utf-8 -*-
from django.core.management.base import BaseCommand
from repanier.const import PERMANENCE_CLOSED, \
PERMANENCE_INVOICED, PERMANENCE_ARCHIVED, PERMANENCE_SEND
from repanier.models import Permanence
from repanier.models.permanence import Permanence
class Command(BaseCommand):
......
# -*- coding: utf-8 -*-
from django.core.management.base import BaseCommand
from repanier.const import PERMANENCE_CLOSED
from repanier.models import Permanence
from repanier.models.permanence import Permanence
class Command(BaseCommand):
......
......@@ -23,9 +23,9 @@ from djangocms_text_ckeditor.fields import HTMLField
from menus.menu_pool import menu_pool
from parler.models import TranslatableModel, TranslatedFields
from repanier.models import product
from repanier.const import *
from repanier.fields.RepanierMoneyField import ModelMoneyField
from repanier.models.product import Product
class Configuration(TranslatableModel):
......@@ -321,7 +321,9 @@ def configuration_pre_save(sender, **kwargs):
@receiver(post_save, sender=Configuration)
def configuration_post_save(sender, **kwargs):
import repanier.cms_toolbar
from repanier.models import BankAccount, Producer, Customer
from repanier.models.bankaccount import BankAccount
from repanier.models.producer import Producer
from repanier.models.customer import Customer
config = kwargs["instance"]
if config.id is not None:
......@@ -427,12 +429,12 @@ def configuration_post_save(sender, **kwargs):
represent_this_buyinggroup=True
)
if producer_buyinggroup is not None:
membership_fee_product = product.Product.objects.filter(
membership_fee_product = Product.objects.filter(
order_unit=PRODUCT_ORDER_UNIT_MEMBERSHIP_FEE,
is_active=True
).order_by('?').first()
if membership_fee_product is None:
membership_fee_product = product.Product.objects.create(
membership_fee_product = Product.objects.create(
producer_id=producer_buyinggroup.id,
order_unit=PRODUCT_ORDER_UNIT_MEMBERSHIP_FEE,
vat_level=VAT_100
......@@ -445,22 +447,24 @@ def configuration_post_save(sender, **kwargs):
membership_fee_product.long_name = "%s" % (_("Membership fee"))
membership_fee_product.save()
translation.activate(cur_language)
repanier.apps.REPANIER_SETTINGS_GROUP_PRODUCER_ID = producer_buyinggroup.id
customer_buyinggroup = Customer.objects.filter(represent_this_buyinggroup=True).order_by('?')
if not customer_buyinggroup.exists():
customer_buyinggroup = Customer.objects.filter(represent_this_buyinggroup=True).order_by('?').first()
if customer_buyinggroup is None:
user = User.objects.create_user(
username="z-%s" % repanier.apps.REPANIER_SETTINGS_GROUP_NAME,
email="%s%s" % (
repanier.apps.REPANIER_SETTINGS_GROUP_NAME, settings.DJANGO_SETTINGS_ALLOWED_MAIL_EXTENSION),
password=uuid.uuid1().hex,
first_name=EMPTY_STRING, last_name=repanier.apps.REPANIER_SETTINGS_GROUP_NAME)
Customer.objects.create(
customer_buyinggroup = Customer.objects.create(
user=user,
short_basket_name="z-%s" % repanier.apps.REPANIER_SETTINGS_GROUP_NAME,
long_basket_name=repanier.apps.REPANIER_SETTINGS_GROUP_NAME,
phone1='0499/96.64.32',
represent_this_buyinggroup=True
)
repanier.apps.REPANIER_SETTINGS_GROUP_CUSTOMER_ID = customer_buyinggroup.id
menu_pool.clear()
toolbar_pool.unregister(repanier.cms_toolbar.RepanierToolbar)
......
......@@ -5,22 +5,24 @@ import datetime
from django.conf import settings
from django.core import urlresolvers
from django.core.signing import TimestampSigner, BadSignature, SignatureExpired
from django.core.validators import MinValueValidator
from django.db import models
from django.db.models import Q, Sum
from django.db.models.signals import post_delete, pre_save
from django.dispatch import receiver
from django.urls import reverse
from django.utils import timezone
from django.utils.encoding import python_2_unicode_compatible
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from repanier.models import bankaccount
from repanier.models import invoice
from repanier.models import permanenceboard
from repanier.models import purchase
# from repanier.models.purchase import Purchase
from repanier.const import *
from repanier.fields.RepanierMoneyField import ModelMoneyField, RepanierMoney
from repanier.models.bankaccount import BankAccount
from repanier.models.invoice import CustomerInvoice
from repanier.models.permanenceboard import PermanenceBoard
from repanier.picture.const import SIZE_S
from repanier.picture.fields import AjaxPictureField
......@@ -132,7 +134,7 @@ class Customer(models.Model):
def get_order_not_invoiced(self):
from repanier.apps import REPANIER_SETTINGS_INVOICE
if