Skip to content

Commit

Permalink
migration to dj1.8 - first alpha version
Browse files Browse the repository at this point in the history
  • Loading branch information
mwolff44 committed Oct 13, 2016
1 parent 80ca03c commit d875f93
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 53 deletions.
15 changes: 8 additions & 7 deletions customerportal/views.py
Expand Up @@ -77,8 +77,8 @@ def rates_csv_view(request, *args, **kwargs):
.order_by('priority')
qs = qs.filter(ratecard__pk=ratecard)
except Person.DoesNotExist:
messages.error(request,
_(u"""This user is not linked to a customer !"""))
messages.error(request,
_(u"""This user is not linked to a customer !"""))

if ratecard and int(ratecard) and ratecard in rc:
ratecard = int(ratecard)
Expand Down Expand Up @@ -117,8 +117,8 @@ def csv_view(request, *args, **kwargs):
.exclude(effective_duration="0")\
.order_by('-start_stamp')
except Person.DoesNotExist:
messages.error(request,
_(u"""This user is not linked to a customer !"""))
messages.error(request,
_(u"""This user is not linked to a customer !"""))

if day and int(day) < 8 and int(day) > 0:
day = int(day)
Expand All @@ -139,9 +139,10 @@ def csv_view(request, *args, **kwargs):
else:
qs.none()
# import pdb; pdb.set_trace()
return render_to_csv_response(qs,
append_datestamp=True,
field_header_map={'customer__name': 'Customer'})
return render_to_csv_response(
qs,
append_datestamp=True,
field_header_map={'customer__name': 'Customer'})


class Template404View(LoginRequiredMixin, TemplateView):
Expand Down
8 changes: 4 additions & 4 deletions pyfreebill/admin.py
Expand Up @@ -350,9 +350,9 @@ def get_form(self, request, obj=None, **kwargs):

return super(CompanyAdmin, self).get_form(request, obj, **kwargs)

def queryset(self, request):
def get_queryset(self, request):
user = getattr(request, 'user', None)
qs = super(CompanyAdmin, self).queryset(request)
qs = super(CompanyAdmin, self).get_queryset(request)
if user.is_superuser:
return qs
else:
Expand Down Expand Up @@ -1316,11 +1316,11 @@ def get_form(self, request, obj=None, **kwargs):
self.exclude.append('cost_destination')
return super(CDRAdmin, self).get_form(request, obj, **kwargs)

def queryset(self, request):
def get_queryset(self, request):
today_c = date.today() - datetime.timedelta(days=settings.PFB_NB_CUST_CDR)
today_a = date.today() - datetime.timedelta(days=settings.PFB_NB_ADMIN_CDR)
user = getattr(request, 'user', None)
qs = super(CDRAdmin, self).queryset(request)
qs = super(CDRAdmin, self).get_queryset(request)
# add .prefetch_related('content_type') for reduce queries
if user.is_superuser:
return qs.filter(start_stamp__gte=today_a)
Expand Down
2 changes: 1 addition & 1 deletion pyfreebilling/__init__.py
Expand Up @@ -20,7 +20,7 @@
from django.utils.version import get_git_changeset


VERSION = (1, 7, 0, 'final', 0)
VERSION = (1, 8, 0, 'alpha', 0)


def get_version(version=None):
Expand Down
9 changes: 2 additions & 7 deletions pyfreebilling/settings.py
Expand Up @@ -122,17 +122,13 @@
)

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'request.middleware.RequestMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'djangosecure.middleware.SecurityMiddleware',
'axes.middleware.FailedLoginMiddleware',
# For django < 1.6
'yawdadmin.middleware.PopupMiddleware',
# Uncomment the next line for simple clickjacking protection:
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

Expand Down Expand Up @@ -184,7 +180,6 @@
'datetimewidget',
'bootstrap3',
'currencies',
'djangosecure',
'django_tables2',
'bootstrap_toolkit',
'bootstrap_pagination',
Expand Down
2 changes: 0 additions & 2 deletions pyfreebilling/urls.py
Expand Up @@ -341,6 +341,4 @@ def perms_func(request, item):
url(regex=r'^chart_stats_general_json/$',
view=chart_stats_general_json,
name='chart_stats_general_json'),
url(r'^extranet/',
include("massadmin.urls")),
url(r'^currencies/', include('currencies.urls')), )
3 changes: 3 additions & 0 deletions requirements/requirements-dev.in
@@ -0,0 +1,3 @@
django-extensions==1.7.4 # python manage.py runserver_plus --cert /etc/ssl/private/localhost.pem
werkzeug==0.11.11
pyOpenSSL==16.1.0
21 changes: 21 additions & 0 deletions requirements/requirements-dev.txt
@@ -0,0 +1,21 @@
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile --output-file requirements/requirements-dev.txt requirements/requirements-dev.in
#
cffi==1.8.3 # via cryptography
cryptography==1.5.2 # via pyopenssl
django-extensions==1.7.4
enum34==1.1.6 # via cryptography
idna==2.1 # via cryptography
ipaddress==1.0.17 # via cryptography
pyasn1==0.1.9 # via cryptography
pycparser==2.14 # via cffi
pyOpenSSL==16.1.0
six==1.10.0 # via cryptography, django-extensions, pyopenssl
werkzeug==0.11.11

# The following packages are commented out because they are
# considered to be unsafe in a requirements file:
# setuptools # via cryptography
21 changes: 10 additions & 11 deletions requirements/requirements.in
@@ -1,31 +1,30 @@
# requirements.in

Django==1.7.11
django==1.8.15
django-admin-honeypot==1.0.0
django-axes==1.6.0
django-axes==2.2.0
django-bootstrap-pagination==1.6.2
django-bootstrap-toolkit==2.15.0
django-bootstrap3==6.2.2
django-bootstrap3==7.1.0
django-braces==1.9.0
django-chroniker==0.9.3
django-clear-cache==0.3
django-countries==3.4.1
django-countries==4.0
django-crispy-forms==1.6.0
django-currencies==0.4.0
django-datetime-widget==0.9.3
## -- to be upated
django-import-export==0.5.1
django-qsstats-magic==0.7.2
django-queryset-csv==0.3.3
django-mathfilters==0.4.0
django-secure==1.0.1 # rezmoved in dj1.8
django-simple-import==1.17
django-tables2==1.1.2
django-simple-import==2.0.1
django-tables2==1.2.6
FreeSWITCH-ESL-Python==1.2
netaddr==0.7.18
netifaces==0.10.5
psycopg2==2.6.2
# raven==5.13.0
# requests==2.9.1
raven==5.27.1
requests==2.11.1
pytz==2016.7
vatnumber==1.2
-e git+https://github.com/mwolff44/yawd-admin.git@0.7.2#egg=yawd-admin
-e git+https://github.com/mwolff44/yawd-admin.git@0.7.3#egg=yawd-admin
26 changes: 12 additions & 14 deletions requirements/requirements.txt
Expand Up @@ -4,46 +4,44 @@
#
# pip-compile --output-file requirements/requirements.txt requirements/requirements.in
#
-e git+https://github.com/mwolff44/yawd-admin.git@0.7.2#egg=yawd-admin
-e git+https://github.com/mwolff44/yawd-admin.git@0.7.3#egg=yawd-admin
contextlib2==0.5.4 # via raven
diff-match-patch==20121119 # via django-import-export
django-admin-honeypot==1.0.0
django-axes==1.6.0
django-axes==2.2.0
django-bootstrap-pagination==1.6.2
django-bootstrap-toolkit==2.15.0
django-bootstrap3==6.2.2
django-bootstrap3==7.1.0
django-braces==1.9.0
django-chroniker==0.9.3
django-clear-cache==0.3
django-countries==3.4.1
django-countries==4.0
django-crispy-forms==1.6.0
django-currencies==0.4.0
django-datetime-widget==0.9.3
django-import-export==0.5.1
django-mathfilters==0.4.0
django-qsstats-magic==0.7.2
django-secure==1.0.1
django-simple-import==1.17
django-tables2==1.1.2
Django==1.7.11 # via django-chroniker, django-clear-cache, django-currencies, django-datetime-widget, django-secure, django-simple-import, django-tables2
et-xmlfile==1.0.1 # via openpyxl
django-queryset-csv==0.3.3
django-simple-import==2.0.1
django-tables2==1.2.6
django==1.8.15
FreeSWITCH-ESL-Python==1.2
httplib2==0.9.2 # via oauth2client
jdcal==1.3 # via openpyxl
netaddr==0.7.18
netifaces==0.10.5
oauth2client==1.4.12
odfpy==1.3.3 # via django-simple-import
openpyxl==2.4.0 # via django-simple-import
psutil==4.1.0 # via django-chroniker
psycopg2==2.6.2
pyasn1-modules==0.0.8 # via oauth2client
pyasn1==0.1.9 # via oauth2client, pyasn1-modules, rsa
python-dateutil==2.5.3 # via django-chroniker
python-stdnum==1.4 # via vatnumber
pytz==2016.7
raven==5.27.1
requests==2.11.1
rsa==3.4.2 # via oauth2client
six==1.10.0 # via django-chroniker, django-tables2, oauth2client, python-dateutil
six==1.10.0 # via django-chroniker, oauth2client, python-dateutil
tablib==0.11.2 # via django-import-export
toposort==1.4 # via django-chroniker
vatnumber==1.2
xlrd==1.0.0 # via django-simple-import
3 changes: 1 addition & 2 deletions setup/apache/001-pyfreebilling
Expand Up @@ -37,5 +37,4 @@
</IfVersion>
</Directory>
</VirtualHost>

#WSGIPythonPath /usr/src/wikipbx:/usr/src/django:/usr/src/freeswitch/libs/esl/python
WSGIPythonPath /usr/local/venv/pyfreebilling:/usr/local/venv/lib/python2.7/site-packages
8 changes: 5 additions & 3 deletions switch/views.py
Expand Up @@ -28,7 +28,6 @@
import logging
import os
import platform
import psutil
import socket
import time

Expand Down Expand Up @@ -60,6 +59,7 @@ def fs_status_view(request):
return render_to_response('admin/fs_status.html', locals(),
context_instance=RequestContext(request))


@staff_member_required
def fs_registry_view(request):
try:
Expand All @@ -70,6 +70,7 @@ def fs_registry_view(request):
return render_to_response('admin/fs_status.html', locals(),
context_instance=RequestContext(request))


@staff_member_required
def fs_bcalls_view(request):
try:
Expand All @@ -89,6 +90,7 @@ def fs_bcalls_view(request):
# bar_chart.add('idle', cputimes.idle)
# return HttpResponse(bar_chart.render(), content_type="image/svg+xml")


@staff_member_required
def server_status_view(request):
sysinfo = psdash.get_sysinfo()
Expand All @@ -97,7 +99,7 @@ def server_status_view(request):
memory = psdash.get_memory()
mem_wo_c = memory['total'] - memory['available']
netifs = psdash.get_network_interfaces().values()
net_interfaces = netifs #.sort(key=lambda x: x.get('bytes_sent'), reverse=True)
net_interfaces = netifs # .sort(key=lambda x: x.get('bytes_sent'), reverse=True)
os = sysinfo['os'].decode('utf-8')
hostname = sysinfo['hostname'].decode('utf-8')
uptime = uptime
Expand All @@ -108,4 +110,4 @@ def server_status_view(request):
cpu = psdash.get_cpu()
users = psdash.get_users()
return render_to_response('admin/server_status.html', locals(),
context_instance=RequestContext(request))
context_instance=RequestContext(request))
4 changes: 2 additions & 2 deletions wsgi.py
Expand Up @@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with pyfreebilling. If not, see <http://www.gnu.org/licenses/>

import django.core.handlers.wsgi
from django.core.wsgi import get_wsgi_application

import os
import sys
Expand All @@ -34,4 +34,4 @@
sys.path.insert(0, root)
os.environ['DJANGO_SETTINGS_MODULE'] = 'pyfreebilling.settings'

application = django.core.handlers.wsgi.WSGIHandler()
application = get_wsgi_application()

0 comments on commit d875f93

Please sign in to comment.