Commit 1b59026c authored by Patrick Colmant's avatar Patrick Colmant Committed by GitHub

Merge pull request #1 from tobald/master

Ease local development
parents 4ba251ca 19c18faa
**/__pycache__
*.pyc
venv
.ropeproject
......@@ -29,3 +29,30 @@ https://commande.lebuisson.be/fr/
https://saisonsvanbiervliet.be/fr/
Licence : GPL v3
Development instructions
------------------------
1. Clone repository:
git clone https://github.com/pcolmant/repanier.git
2. Initialize python virtual environment
virtualenv -p python3 venv
3. Activate it
. venv/bin/activate
4. Install python dependencies
pip install -r requirements/requirement.txt
5. Synchronize database
./manage.py migrate
6. Launch the application
./manage.py runserver
#!/bin/sh
# initialize environment for repanier development
#
# please apt-get install python3-dev
virtualenv -p python3 venv
venv/bin/pip install -r requirements/requirement.txt
# activate environment before executing django commands:
#
# $ . venv/bin/activate
# $ ./manage.py migrate
# $ ./manage.py runserver
# ...
......@@ -7,6 +7,10 @@ if __name__ == "__main__":
os_environ = "DJANGO_SETTINGS_MODULE"
project = os.path.split(os.path.abspath(os.path.dirname(__file__)))[-1]
# Settings are set according to directory name
# Assume developement environment by default
if project == 'repanier':
project = 'mysite'
django_settings = "%s.common_settings" % project
os.environ.setdefault(os_environ, django_settings)
if os.environ.get(os_environ) != django_settings:
......@@ -15,4 +19,4 @@ if __name__ == "__main__":
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
\ No newline at end of file
execute_from_command_line(sys.argv)
......@@ -11,7 +11,7 @@ from django.utils.translation import get_language_info
from django.utils.translation import ugettext_lazy as _
from repanier.const import *
from settings import *
from .settings import *
import os
......
[DJANGO_SETTINGS]
; test settings for repanier
DJANGO_SETTINGS_ADMIN_EMAIL=admin@locahost
DJANGO_SETTINGS_ADMIN_NAME=admin
DJANGO_SETTINGS_DATABASE_HOST=default
DJANGO_SETTINGS_DATABASE_NAME=db.sqlite3
DJANGO_SETTINGS_DATABASE_PASSWORD=
DJANGO_SETTINGS_DATABASE_PORT=0
DJANGO_SETTINGS_DATABASE_USER=
DJANGO_SETTINGS_DEBUG=True
DJANGO_SETTINGS_DEMO=True
DJANGO_SETTINGS_EMAIL_HOST=localhost
DJANGO_SETTINGS_EMAIL_HOST_PASSWORD=
DJANGO_SETTINGS_EMAIL_HOST_USER=
DJANGO_SETTINGS_EMAIL_PORT=0
DJANGO_SETTINGS_EMAIL_USE_SSL=False
DJANGO_SETTINGS_EMAIL_USE_TLS=False
DJANGO_SETTINGS_ENV=dev
DJANGO_SETTINGS_LANGUAGE=Fr
DJANGO_SETTINGS_LOGGING=True
DJANGO_SETTINGS_CACHE=True
DJANGO_SETTINGS_SESSION=
DJANGO_SETTINGS_COUNTRY=Be
DJANGO_SETTINGS_STATIC=/tmp
[ALLOWED_HOSTS]
localhost=localhost
# placeholder
SECRET_KEY = 1234
......@@ -2,47 +2,47 @@
from django.contrib import admin
from repanier.models import BankAccount
from bankaccount import BankAccountAdmin
from .bankaccount import BankAccountAdmin
admin.site.register(BankAccount, BankAccountAdmin)
from repanier.models import Configuration
from configuration import ConfigurationAdmin
from .configuration import ConfigurationAdmin
admin.site.register(Configuration, ConfigurationAdmin)
from repanier.models import Customer
from customer import CustomerWithUserDataAdmin
from .customer import CustomerWithUserDataAdmin
admin.site.register(Customer, CustomerWithUserDataAdmin)
from repanier.models import Purchase
from purchase import PurchaseAdmin
from .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 .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 .offeritem import OfferItemClosedAdmin
admin.site.register(OfferItemClosed, OfferItemClosedAdmin)
from repanier.models import OfferItemSend
from rule_of_3_per_product import OfferItemSendAdmin
from .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 .rule_of_3_per_customer import CustomerSendAdmin
admin.site.register(CustomerSend, CustomerSendAdmin)
from repanier.models import PermanenceInPreparation
from permanence_in_preparation import PermanenceInPreparationAdmin
from .permanence_in_preparation import PermanenceInPreparationAdmin
admin.site.register(PermanenceInPreparation, PermanenceInPreparationAdmin)
from repanier.models import PermanenceDone
from permanence_done import PermanenceDoneAdmin
from .permanence_done import PermanenceDoneAdmin
admin.site.register(PermanenceDone, PermanenceDoneAdmin)
from repanier.models import Producer
from producer import ProducerAdmin
from .producer import ProducerAdmin
admin.site.register(Producer, ProducerAdmin)
from repanier.models import Product
from product import ProductAdmin
from .product import ProductAdmin
admin.site.register(Product, ProductAdmin)
from repanier.models.box import Box
from box import BoxAdmin
from .box import BoxAdmin
admin.site.register(Box, BoxAdmin)
from repanier.models import Staff
from staff import StaffWithUserDataAdmin
from .staff import StaffWithUserDataAdmin
admin.site.register(Staff, StaffWithUserDataAdmin)
......@@ -10,7 +10,7 @@ from django.utils.translation import ugettext_lazy as _
from easy_select2 import apply_select2
from parler.forms import TranslatableModelForm
from lut import LUTAdmin
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
......
......@@ -67,9 +67,10 @@ class RepanierSettings(AppConfig):
try:
db_started = connection.cursor() is not None
except:
print("waiting for database connection")
time.sleep(1)
from models import Configuration, LUT_DepartmentForCustomer, Product
from const import DECIMAL_ONE, PERMANENCE_NAME_PERMANENCE, CURRENCY_EUR, ORDER_GROUP, \
from repanier.models import Configuration, LUT_DepartmentForCustomer, Product
from repanier.const import DECIMAL_ONE, PERMANENCE_NAME_PERMANENCE, CURRENCY_EUR, ORDER_GROUP, \
INVOICE_GROUP, CONTRIBUTOR_GROUP, COORDINATION_GROUP, WEBMASTER_GROUP
try:
# Create if needed and load RepanierSettings var when performing config.save()
......
# -*- coding: utf-8
# non proxies
from bankaccount import BankAccount
from configuration import Configuration
from customer import Customer
from deliveryboard import DeliveryBoard
from invoice import CustomerInvoice, ProducerInvoice, CustomerProducerInvoice
from lut import LUT_ProductionMode, LUT_DeliveryPoint, LUT_DepartmentForCustomer, LUT_PermanenceRole
from offeritem import OfferItem
from permanence import Permanence
from permanenceboard import PermanenceBoard
from producer import Producer
from product import Product, Product_Translation
from purchase import Purchase
from staff import Staff
from .bankaccount import BankAccount
from .configuration import Configuration
from .customer import Customer
from .deliveryboard import DeliveryBoard
from .invoice import CustomerInvoice, ProducerInvoice, CustomerProducerInvoice
from .lut import LUT_ProductionMode, LUT_DeliveryPoint, LUT_DepartmentForCustomer, LUT_PermanenceRole
from .offeritem import OfferItem
from .permanence import Permanence
from .permanenceboard import PermanenceBoard
from .producer import Producer
from .product import Product, Product_Translation
from .purchase import Purchase
from .staff import Staff
# after Producer and Product
from box import BoxContent
from .box import BoxContent
# proxies
from box import Box
from invoice import CustomerSend
from offeritem import OfferItemSend, OfferItemClosed, OfferItemWoReceiver
from permanence import PermanenceInPreparation, PermanenceDone
\ No newline at end of file
from .box import Box
from .invoice import CustomerSend
from .offeritem import OfferItemSend, OfferItemClosed, OfferItemWoReceiver
from .permanence import PermanenceInPreparation, PermanenceDone
......@@ -23,7 +23,7 @@ from djangocms_text_ckeditor.fields import HTMLField
from menus.menu_pool import menu_pool
from parler.models import TranslatableModel, TranslatedFields
import product
from repanier.models import product
from repanier.const import *
from repanier.fields.RepanierMoneyField import ModelMoneyField
......
......@@ -15,10 +15,10 @@ from django.utils.encoding import python_2_unicode_compatible
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
import bankaccount
import invoice
import permanenceboard
import purchase
from repanier.models import bankaccount
from repanier.models import invoice
from repanier.models import permanenceboard
from repanier.models import purchase
from repanier.const import *
from repanier.fields.RepanierMoneyField import ModelMoneyField, RepanierMoney
from repanier.picture.const import SIZE_S
......
......@@ -11,8 +11,8 @@ from django.utils.translation import ugettext_lazy as _
from menus.menu_pool import menu_pool
from parler.models import TranslatableModel, TranslatedFields
import invoice
import purchase
from repanier.models import invoice
from repanier.models import purchase
from repanier.apps import REPANIER_SETTINGS_PERMANENCE_NAME
from repanier.const import LUT_PERMANENCE_STATUS, PERMANENCE_PLANNED, PERMANENCE_SEND, EMPTY_STRING
......
......@@ -12,9 +12,9 @@ from django.utils.formats import number_format
from django.utils.text import slugify
from django.utils.translation import ugettext_lazy as _
import producer
import purchase
import deliveryboard
from repanier.models import producer
from repanier.models import purchase
from repanier.models import deliveryboard
from repanier.apps import DJANGO_IS_MIGRATION_RUNNING
from repanier.const import *
from repanier.fields.RepanierMoneyField import ModelMoneyField
......
......@@ -12,7 +12,7 @@ from django.utils.translation import ugettext_lazy as _
from djangocms_text_ckeditor.fields import HTMLField
from parler.models import TranslatedFields
import invoice
from repanier.models import invoice
from repanier.models.item import Item
from repanier.apps import REPANIER_SETTINGS_PERMANENCE_NAME
from repanier.const import *
......
......@@ -17,13 +17,13 @@ from djangocms_text_ckeditor.fields import HTMLField
from menus.menu_pool import menu_pool
from parler.models import TranslatableModel, TranslatedFields, TranslationDoesNotExist
import customer
import deliveryboard
import invoice
import offeritem
import permanenceboard
import producer
import purchase
from repanier.models import customer
from repanier.models import deliveryboard
from repanier.models import invoice
from repanier.models import offeritem
from repanier.models import permanenceboard
from repanier.models import producer
from repanier.models import purchase
import repanier.apps
from repanier.picture.const import SIZE_L
from repanier.picture.fields import AjaxPictureField
......
......@@ -19,10 +19,10 @@ from django.utils.formats import number_format
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
import bankaccount
import invoice
import offeritem
import product
from repanier.models import bankaccount
from repanier.models import invoice
from repanier.models import offeritem
from repanier.models import product
from repanier.const import *
from repanier.fields.RepanierMoneyField import ModelMoneyField, RepanierMoney
from repanier.tools import update_offer_item
......@@ -372,4 +372,4 @@ def producer_post_save(sender, **kwargs):
producer = kwargs["instance"]
for a_product in product.Product.objects.filter(producer_id=producer.id).order_by('?'):
a_product.save()
update_offer_item(producer_id=producer.id)
\ No newline at end of file
update_offer_item(producer_id=producer.id)
......@@ -11,10 +11,10 @@ from django.dispatch import receiver
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
import invoice
import offeritem
import permanence
import producer
from repanier.models import invoice
from repanier.models import offeritem
from repanier.models import permanence
from repanier.models import producer
import repanier.apps
from repanier.const import *
from repanier.fields.RepanierMoneyField import ModelMoneyField
......
# -*- coding: utf-8
from __future__ import unicode_literals
from const import SIZE_XS, SIZE_S, SIZE_M, SIZE_L
from .const import SIZE_XS, SIZE_S, SIZE_M, SIZE_L
from repanier.tools import sint
try:
......
......@@ -10,7 +10,7 @@ from django.forms import widgets
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext as _
from const import SIZE_M
from repanier.picture.const import SIZE_M
from repanier.const import EMPTY_STRING
......
......@@ -33,8 +33,8 @@ from django.utils.text import slugify
from django.utils.translation import ugettext_lazy as _
from six import string_types
import models
from const import *
from repanier import models
from repanier.const import *
from repanier import apps
from repanier.fields.RepanierMoneyField import RepanierMoney
......
......@@ -5,7 +5,7 @@ from django.contrib.auth.decorators import login_required
from django.views.decorators.cache import never_cache
# from django.views.i18n import JavaScriptCatalog
from picture.views import ajax_picture
from repanier.picture.views import ajax_picture
from repanier.rest.lut import departments_for_customers_rest, department_for_customer_rest
from repanier.rest.permanence import permanences_rest, permanence_producer_product_rest, \
permanence_producer_rest
......
......@@ -13,7 +13,7 @@ from django.views.decorators.cache import never_cache
from django.views.decorators.csrf import csrf_protect
from django.views.decorators.debug import sensitive_post_parameters
from forms import AuthRepanierLoginForm
from repanier.views.forms import AuthRepanierLoginForm
from repanier.models import Staff
from repanier.const import EMPTY_STRING, ORDER_GROUP, INVOICE_GROUP, WEBMASTER_GROUP, CONTRIBUTOR_GROUP, \
COORDINATION_GROUP
......
......@@ -8,7 +8,7 @@ from django.shortcuts import get_object_or_404, render
from django.utils.translation import ugettext_lazy as _
from django.views.decorators.cache import never_cache
from forms import ProducerProductForm
from repanier.views.forms import ProducerProductForm
from repanier.const import DECIMAL_ZERO, DECIMAL_ONE, PRODUCT_ORDER_UNIT_PC_PRICE_KG, TWO_DECIMALS, ONE_DECIMAL, \
PRODUCT_ORDER_UNIT_PC_KG, PERMANENCE_PRE_OPEN, EMPTY_STRING, VAT_400
from repanier.models import Producer, Permanence, Product, OfferItem
......
......@@ -7,7 +7,7 @@ from django.http import Http404
from django.shortcuts import get_object_or_404, render
from django.views.decorators.cache import never_cache
from forms import ProducerProductForm
from repanier.views.forms import ProducerProductForm
from repanier.const import ONE_DECIMAL, TWO_DECIMALS, DECIMAL_ZERO, PRODUCT_ORDER_UNIT_PC_KG, DECIMAL_ONE, \
PERMANENCE_PRE_OPEN
from repanier.models import Producer, OfferItem
......
......@@ -4,7 +4,7 @@ from __future__ import unicode_literals
from itertools import chain
from django import forms
from django.utils.encoding import force_unicode
from django.utils.encoding import force_text
from django.utils.html import escape, conditional_escape
from django.utils.safestring import mark_safe
......@@ -47,7 +47,7 @@ class SelectBootstrapWidget(forms.Select):
return mark_safe(output)
def render_option2(self, selected_choices, option_value, option_label, name):
option_value = force_unicode(option_value)
option_value = force_text(option_value)
if option_value in selected_choices:
selected_html = ' selected="selected"'
self.selected_choice = option_label
......@@ -56,11 +56,11 @@ class SelectBootstrapWidget(forms.Select):
return '<li><a href="javascript:%s_select(\'%s\', \'%s\')" data-value="%s"%s>%s</a></li>' % (
name, option_value, option_label,
escape(option_value), selected_html,
conditional_escape(force_unicode(option_label)))
conditional_escape(force_text(option_label)))
def render_options2(self, choices, selected_choices, name):
# Normalize to strings.
selected_choices = set([force_unicode(v) for v in selected_choices])
selected_choices = set([force_text(v) for v in selected_choices])
output = []
for option_value, option_label in chain(self.choices, choices):
output.append(self.render_option2(selected_choices, option_value, option_label, name))
......
......@@ -4,7 +4,7 @@ from __future__ import unicode_literals
from itertools import chain
from django import forms
from django.utils.encoding import force_unicode
from django.utils.encoding import force_text
from django.utils.html import escape, conditional_escape
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
......@@ -126,7 +126,7 @@ class SelectProducerOrderUnitWidget(forms.Select):
return mark_safe(output)
def render_option2(self, selected_choices, option_value, option_label, name):
option_value = force_unicode(option_value)
option_value = force_text(option_value)
if option_value in selected_choices:
selected_html = ' selected="selected"'
self.selected_choice = option_label
......@@ -167,11 +167,11 @@ class SelectProducerOrderUnitWidget(forms.Select):
name, option_value, option_label, increment_order_quantity_label,
stock_label, increment_order_quantity_addon, stock_addon, price_addon,
escape(option_value), selected_html,
conditional_escape(force_unicode(option_label)))
conditional_escape(force_text(option_label)))
def render_options2(self, choices, selected_choices, name):
# Normalize to strings.
selected_choices = set([force_unicode(v) for v in selected_choices])
selected_choices = set([force_text(v) for v in selected_choices])
output = []
for option_value, option_label in chain(self.choices, choices):
output.append(self.render_option2(selected_choices, option_value, option_label, name))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment