Skip to content

Latest commit

 

History

History
158 lines (119 loc) · 3.57 KB

README.md

File metadata and controls

158 lines (119 loc) · 3.57 KB

PREVIEW IMAGES

Preview 1

Preview 2

Preview 3

Preview 4

DEVELOPMENT

Initial create project:

virtualenv -p python2 --prompt="(cdr-viewer)" venv
. venv/bin/activate
pip install --upgrade pip
django-admin startproject cdr .
python manage.py migrate
python manage.py createsuperuser
python manage.py collectstatic

Migrations

If models.py was chenged, run again:

python manage.py makemigrations cdr
python manage.py migrate

Apply migrations

python manage.py migrate --database pbx cdr

Custom admin

Create custom admin area for manage users:

django-admin.py startapp customuseradmin

Code customuseradmin/admin.py:

# -*- coding:utf-8 -*-
from django.contrib import admin
from django.contrib.auth.models import User, Group
from django.contrib.auth.admin import UserAdmin

admin.site.unregister(User)

class CustomUserAdmin(UserAdmin):
    list_display = ('username', 'email', 'is_staff','is_active',)
    list_filter = ('is_staff', 'is_superuser', 'is_active',)
admin.site.register(User, CustomUserAdmin)

Test SMTP Email Server

Run server:

python -m smtpd -n -c DebuggingServer localhost:1025

Localization

Use django way (rocommended)

Initial generate from python code and templates files:

. venv/bin/activate
cd cdr
[ -d locale ] || mkdir locale
python ../manage.py makemessages --locale=ru_RU --no-location
python ../manage.py compilemessages --locale=ru_RU

Update from python code and templates files:

. venv/bin/activate
cd cdr
python ../manage.py makemessages --locale=ru_RU --no-location
python ../manage.py compilemessages --locale=ru_RU

If you get error like this, then you need install gettext package

python ../manage.py makemessages --locale=ru_RU --no-location
CommandError: Can't find msguniq. Make sure you have GNU gettext tools 0.15 or newer installed.

like this for fix error

sudo apt install gettext

Or use native os tools (not recommended)

find accounts/locale -name *.po | sed 's/\.po$//g' | xargs -i{} msgfmt {}.po -o {}.mo

Git delete unwanted file from repo

Be careful! This will overwrite your existing tags.

git filter-branch --force --index-filter \
'git rm --cached --ignore-unmatch cdr/settings.py' \
--prune-empty --tag-name-filter cat -- --all

LINKS

Django translation

Media files

Additional headers for Nginx:

X-Accel-Limit-Rate: 1024
X-Accel-Buffering: yes|no
X-Accel-Charset: utf-8

Note that the following HTTP headers aren't modified by NGINX:

Content-Type
Content-Disposition
Accept-Ranges
Set-Cookie
Cache-Control
Expires

/media_nginx/ cant be equal /media/, because /media_nginx/ is internal and nginx not accept request from external network from users nginx will be accep only internal responses from backed application

3rdparty components