Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ nosetests.xml
# django ERP-specific files
*.db
djangoerp/settings/base.py
venv
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ django ERP
Pre-requisites
--------------

Make sure you have the following pre-requisites installed:
Make sure you have the following pre-requisites installed for python 2 version:

* **python** >= 2.7 (required)
http://www.python.org
Expand All @@ -26,6 +26,8 @@ Make sure you have the following pre-requisites installed:
* **mod_wsgi** (optional)
http://code.google.com/p/modwsgi

Latest code is updated to use python 3. Use `pip install -r requirements.txt` to install the pre-requisites.

Installation
------------

Expand Down
27 changes: 14 additions & 13 deletions djangoerp/core/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
__copyright__ = 'Copyright (c) 2013 Emanuele Bertoldi'
__version__ = '0.0.1'

from utils.dependencies import check_dependency
from djangoerp.core.utils.dependencies import check_dependency

check_dependency('django.contrib.auth')
check_dependency('django.contrib.contenttypes')
Expand All @@ -25,35 +25,36 @@
check_dependency('django.contrib.staticfiles')
check_dependency('django.contrib.admin')
check_dependency('django.contrib.admindocs')
check_dependency('django.contrib.comments')
check_dependency('django.contrib.markup')
check_dependency('django_comments')
check_dependency('django_markup')
check_dependency('django.contrib.redirects')
check_dependency('django.contrib.formtools')

from django.db.models.signals import post_syncdb
from django.db.models.signals import post_migrate
from django.dispatch import receiver

# Installation of application specific stuff.
INSTALLING = False

@receiver(post_migrate)
def install_apps(sender, **kwargs):
global INSTALLING
if INSTALLING:
return

INSTALLING = True

print "Installing apps ..."
print ("Installing apps ...")

from django.conf import settings
for app in settings.INSTALLED_APPS:
if not app.startswith('django.') and (app != "djangoerp.core"):
management = __import__("%s.management" % app, {}, {}, ["install"])
try:
install_func = management.install
# Dynamically import the management module for each app
management = __import__("%s.management" % app, {}, {}, ["install"])
install_func = getattr(management, 'install', None)

if callable(install_func):
print "Installing app %s" % app
print(f"Installing app {app}")
install_func(sender, **kwargs)
except AttributeError:
pass

post_syncdb.connect(install_apps, dispatch_uid="install_apps")
except (ImportError, AttributeError):
pass # Handle missing 'install' function or import errors gracefully
2 changes: 1 addition & 1 deletion djangoerp/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
__version__ = '0.0.1'

import json
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.core.exceptions import ValidationError

def validate_json(value):
Expand Down
3 changes: 2 additions & 1 deletion djangoerp/core/templatetags/breadcrumbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
__version__ = '0.0.1'

from django import template
from django.core.urlresolvers import reverse
# from django.core.urlresolvers import reverse # Legacy
from django.urls import reverse
from django.template.loader import render_to_string
from django.template import Node, NodeList, Variable, Library
from django.template import TemplateSyntaxError, VariableDoesNotExist
Expand Down
2 changes: 1 addition & 1 deletion djangoerp/core/templatetags/modelfuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from django import template
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

register = template.Library()

Expand Down
8 changes: 4 additions & 4 deletions djangoerp/core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
__copyright__ = 'Copyright (c) 2013 Emanuele Bertoldi'
__version__ = '0.0.1'

from django.conf.urls import patterns
from django.urls import path
from django.views.generic import TemplateView

urlpatterns = patterns('',
(r'^$', TemplateView.as_view(template_name="index.html")),
)
urlpatterns = [
path('', TemplateView.as_view(template_name="index.html"), name='home'),
]
Binary file added djangoerp/db.sqlite3
Binary file not shown.
2 changes: 1 addition & 1 deletion djangoerp/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
__copyright__ = 'Copyright (c) 2013 Emanuele Bertoldi'
__version__ = '0.0.1'

from base import *
from .base import *

# Auto-discovering of application specific settings.
for app in INSTALLED_APPS:
Expand Down
50 changes: 38 additions & 12 deletions djangoerp/settings/base.py.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ __version__ = '0.0.1'
import os
import datetime
from pytz import common_timezones
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

PROJECT_PATH = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), os.path.pardir))
THEME_PATH = os.path.join(PROJECT_PATH, 'themes', 'default')
Expand All @@ -35,8 +35,8 @@ MANAGERS = ADMINS

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '', # Or path to database file if using sqlite3.
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': os.path.join(PROJECT_PATH, 'db.sqlite3'), # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
Expand Down Expand Up @@ -153,21 +153,44 @@ TEMPLATE_DIRS = (
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates', # Required for admin
'DIRS': [
os.path.join(THEME_PATH, "templates"),
os.path.join(REPORT_PATH, "templates"),
],
'APP_DIRS': True, # Enable app directories for templates
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

# List of middleware classes to use. Order is important; in the request phase,
# this middleware classes will be applied in the order given, and in the
# response phase the middleware will be applied in reverse order.
MIDDLEWARE_CLASSES = (
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', # Required for session handling
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware', # Required for authentication
'django.middleware.locale.LocaleMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', # Required for messages framework
'django.contrib.redirects.middleware.RedirectFallbackMiddleware',
# Uncomment the next line for simple clickjacking protection:
# Uncomment if you need clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
]


# Root for URL dispatcher.
ROOT_URLCONF = 'djangoerp.urls'
Expand Down Expand Up @@ -216,10 +239,13 @@ INSTALLED_APPS = (
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'django.contrib.comments',
'django.contrib.markup',
# 'django.contrib.comments', # Legacy
# 'django.contrib.contenttypes', # Required by django-contrib-comments
'django_comments',
# 'django.contrib.markup', # Legacy
'django_markup',
'django.contrib.redirects',
'django.contrib.formtools',
# 'django.contrib.formtools', # Legacy

#'south',

Expand Down
56 changes: 31 additions & 25 deletions djangoerp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,25 @@

from django.conf.urls import *
from django.conf import settings
from django.db.models.loading import cache
from django.urls import path, include
# from django.db.models.loading import cache # Legacy

# Workaround for Django's ticket #10405.
# See http://code.djangoproject.com/ticket/10405#comment:10 for more info.
if not cache.loaded:
cache.get_models()
# if not cache.loaded: # Legacy
# cache.get_models()

# Basic URL patterns bootstrap.
urlpatterns = patterns('',)

# urlpatterns = patterns('',) # Legacy
urlpatterns = []
if 'django.contrib.admin' in settings.INSTALLED_APPS:
from django.contrib import admin
admin.autodiscover()
urlpatterns += patterns('', (r'^admin/', include(admin.site.urls)))
if 'django.contrib.admindocs' in settings.INSTALLED_APPS:
urlpatterns += patterns('', (r'^admin/doc/', include('django.contrib.admindocs.urls')))
from django.contrib import admin
admin.autodiscover()
urlpatterns += [path('admin/', admin.site.urls)] # Updated for Django 2.x+

if 'django.contrib.admindocs' in settings.INSTALLED_APPS:
urlpatterns += [path('admin/doc/', include('django.contrib.admindocs.urls'))]


if 'django.contrib.staticfiles' in settings.INSTALLED_APPS:
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
Expand All @@ -42,37 +45,40 @@
LOADING = False

def autodiscover():
""" Auto discover urls of installed applications.
"""
""" Auto discover urls of installed applications. """
global LOADING
if LOADING:
return

LOADING = True

import imp
import importlib

for app in settings.INSTALLED_APPS:
if app.startswith('django.'):
continue
# Step 1: find out the app's __path__.

# Step 1: Find out the app's __path__.
try:
app_path = __import__(app, {}, {}, [app.split('.')[-1]]).__path__
except AttributeError:
app_module = importlib.import_module(app)
app_path = app_module.__path__
except ImportError:
continue

# Step 2: use imp.find_module to find the app's urls.py.
# Step 2: Check if the app has a 'urls.py'.
try:
imp.find_module('urls', app_path)
importlib.import_module(f'{app}.urls')
except ImportError:
continue

# Step 3: return the app's url patterns.
pkg, sep, name = app.rpartition('.')
global urlpatterns
urlpatterns += patterns("", (r'^', include('%s.urls' % app)))

# Step 3: Include the app's URL patterns.
urlpatterns.append(path(f'{app}/', include(f'{app}.urls')))

# Add core.urls explicitly if djangoerp.core is installed
if 'djangoerp.core' in settings.INSTALLED_APPS:
from djangoerp.core import urls as core_urls
urlpatterns.append(path('', include('djangoerp.core.urls')))

LOADING = False

autodiscover()
18 changes: 18 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
asgiref==3.8.1
bleach==6.2.0
Django==5.1.3
django-contrib-comments==2.2.0
django-formtools==2.5.1
django-markup==1.9
docutils==0.21.2
Markdown==3.7
nh3==0.2.18
Pygments==2.18.0
python-creole==1.4.10
pytz==2024.2
regex==2024.11.6
smartypants==2.0.1
sqlparse==0.5.1
textile==4.0.3
typing_extensions==4.12.2
webencodings==0.5.1