Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main #83

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Main #83

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
24 changes: 18 additions & 6 deletions etc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
CherryPy==6.0.1
click==6.6
Django==1.7.11
future==0.16.0
six==1.10.0
xlrd==1.0.0
asgiref==3.2.10
cheroot==8.3.0
CherryPy==18.6.0
click==7.1.2
Django==3.0.7
future==0.18.2
jaraco.classes==3.1.0
jaraco.collections==3.0.0
jaraco.functools==3.0.1
jaraco.text==3.2.0
more-itertools==8.4.0
portend==2.6
pytz==2020.1
six==1.15.0
sqlparse==0.3.1
tempora==3.0.0
xlrd==1.2.0
zc.lockfile==2.0
3 changes: 2 additions & 1 deletion src/bots/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
class BotsAdmin(admin.ModelAdmin):
''' all classes in this module are sub-classed from BotsAdmin.
'''
list_per_page = botsglobal.ini.getint('settings', 'adminlimit', botsglobal.ini.getint('settings', 'limit', 30))
# list_per_page = botsglobal.ini.getint('settings', 'adminlimit', botsglobal.ini.getint('settings', 'limit', 30))
list_per_page = 30
save_as = True

def activate(self, request, queryset):
Expand Down
60 changes: 30 additions & 30 deletions src/bots/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class View(django.forms.Form):
class SelectReports(Select):
template = 'bots/selectform.html'
action = '/reports/'
status = django.forms.ChoiceField([models.DEFAULT_ENTRY, ('1', 'Error'), ('0', 'Done')], required=False, initial='')
status = django.forms.ChoiceField(choices=[models.DEFAULT_ENTRY, ('1', 'Error'), ('0', 'Done')], required=False, initial='')


class ViewReports(View):
Expand All @@ -42,16 +42,16 @@ class ViewReports(View):
class SelectIncoming(Select):
template = 'bots/selectform.html'
action = '/incoming/'
statust = django.forms.ChoiceField([models.DEFAULT_ENTRY, ('1', 'Error'),
statust = django.forms.ChoiceField(choice=[models.DEFAULT_ENTRY, ('1', 'Error'),
('3', 'Done')], required=False, initial='')
idroute = django.forms.ChoiceField([], required=False, initial='')
fromchannel = django.forms.ChoiceField([], required=False)
frompartner = django.forms.ChoiceField([], required=False)
topartner = django.forms.ChoiceField([], required=False)
ineditype = django.forms.ChoiceField(models.EDITYPESLIST, required=False)
inmessagetype = django.forms.ChoiceField([], required=False)
outeditype = django.forms.ChoiceField(models.EDITYPESLIST, required=False)
outmessagetype = django.forms.ChoiceField([], required=False)
idroute = django.forms.ChoiceField(choice=[], required=False, initial='')
fromchannel = django.forms.ChoiceField(choice=[], required=False)
frompartner = django.forms.ChoiceField(choice=[], required=False)
topartner = django.forms.ChoiceField(choice=[], required=False)
ineditype = django.forms.ChoiceField(choice=models.EDITYPESLIST, required=False)
inmessagetype = django.forms.ChoiceField(choice=[], required=False)
outeditype = django.forms.ChoiceField(choice=models.EDITYPESLIST, required=False)
outmessagetype = django.forms.ChoiceField(choice=[], required=False)
infilename = django.forms.CharField(required=False, label='Filename', max_length=70)
lastrun = django.forms.BooleanField(required=False, initial=False)

Expand Down Expand Up @@ -86,10 +86,10 @@ class SelectDocument(Select):
action = '/document/'
status = django.forms.TypedChoiceField(
[(0, '---------'), (320, _('Document-in')), (330, _('Document-out'))], required=False, initial=0, coerce=int)
idroute = django.forms.ChoiceField([], required=False, initial='')
frompartner = django.forms.ChoiceField([], required=False)
topartner = django.forms.ChoiceField([], required=False)
editype = django.forms.ChoiceField(models.EDITYPESLIST, required=False)
idroute = django.forms.ChoiceField(choice=[], required=False, initial='')
frompartner = django.forms.ChoiceField(choice=[], required=False)
topartner = django.forms.ChoiceField(choice=[], required=False)
editype = django.forms.ChoiceField(choice=models.EDITYPESLIST, required=False)
messagetype = django.forms.ChoiceField(required=False)
lastrun = django.forms.BooleanField(required=False, initial=False)
reference = django.forms.CharField(required=False, label='Reference', max_length=70)
Expand Down Expand Up @@ -118,13 +118,13 @@ class ViewDocument(View):
class SelectOutgoing(Select):
template = 'bots/selectform.html'
action = '/outgoing/'
statust = django.forms.ChoiceField([models.DEFAULT_ENTRY, ('1', 'Error'),
statust = django.forms.ChoiceField(choice=[models.DEFAULT_ENTRY, ('1', 'Error'),
('3', 'Done'), ('4', 'Resend')], required=False, initial='')
idroute = django.forms.ChoiceField([], required=False, initial='')
tochannel = django.forms.ChoiceField([], required=False)
frompartner = django.forms.ChoiceField([], required=False)
topartner = django.forms.ChoiceField([], required=False)
editype = django.forms.ChoiceField(models.EDITYPESLIST, required=False)
idroute = django.forms.ChoiceField(choice=[], required=False, initial='')
tochannel = django.forms.ChoiceField(choice=[], required=False)
frompartner = django.forms.ChoiceField(choice=[], required=False)
topartner = django.forms.ChoiceField(choice=[], required=False)
editype = django.forms.ChoiceField(choice=models.EDITYPESLIST, required=False)
messagetype = django.forms.ChoiceField(required=False)
filename = django.forms.CharField(required=False, label='Filename', max_length=256)
lastrun = django.forms.BooleanField(required=False, initial=False)
Expand Down Expand Up @@ -155,7 +155,7 @@ class ViewOutgoing(View):
class SelectProcess(Select):
template = 'bots/selectform.html'
action = '/process/'
idroute = django.forms.ChoiceField([], required=False, initial='')
idroute = django.forms.ChoiceField(choice=[], required=False, initial='')
lastrun = django.forms.BooleanField(required=False, initial=False)

def __init__(self, *args, **kwargs):
Expand All @@ -173,16 +173,16 @@ class ViewProcess(View):
class SelectConfirm(Select):
template = 'bots/selectform.html'
action = '/confirm/'
confirmtype = django.forms.ChoiceField(models.CONFIRMTYPELIST, required=False, initial='0')
confirmed = django.forms.ChoiceField([('0', 'All runs'), ('1', 'Current run'),
confirmtype = django.forms.ChoiceField(choice=models.CONFIRMTYPELIST, required=False, initial='0')
confirmed = django.forms.ChoiceField(choice=[('0', 'All runs'), ('1', 'Current run'),
('2', 'Last run')], required=False, initial='0')
idroute = django.forms.ChoiceField([], required=False, initial='')
editype = django.forms.ChoiceField(models.EDITYPESLIST, required=False)
messagetype = django.forms.ChoiceField([], required=False)
frompartner = django.forms.ChoiceField([], required=False)
topartner = django.forms.ChoiceField([], required=False)
fromchannel = django.forms.ChoiceField([], required=False)
tochannel = django.forms.ChoiceField([], required=False)
idroute = django.forms.ChoiceField(choice=[], required=False, initial='')
editype = django.forms.ChoiceField(choice=models.EDITYPESLIST, required=False)
messagetype = django.forms.ChoiceField(choice=[], required=False)
frompartner = django.forms.ChoiceField(choice=[], required=False)
topartner = django.forms.ChoiceField(choice=[], required=False)
fromchannel = django.forms.ChoiceField(choice=[], required=False)
tochannel = django.forms.ChoiceField(choice=[], required=False)

def __init__(self, *args, **kwargs):
super(SelectConfirm, self).__init__(*args, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion src/bots/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#~ from django.core.validators import validate_email
from django.core.validators import validate_integer
from django.core.exceptions import ValidationError
from django.utils.encoding import python_2_unicode_compatible
from six import python_2_unicode_compatible
from . import botsglobal
from . import validate_email
''' Declare database tabels.
Expand Down
5 changes: 3 additions & 2 deletions src/bots/pluglib.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import zipimport
import codecs
import django
from django.db import transaction
from django.core import serializers
from django.utils.translation import ugettext as _
from . import models
Expand All @@ -24,7 +25,7 @@
#******************************************


@django.db.transaction.commit_on_success # if no exception raised: commit, else rollback.
@transaction.atomic # if no exception raised: commit, else rollback.
def read_index(filename):
''' process index file in default location. '''
try:
Expand All @@ -51,7 +52,7 @@ def read_index(filename):
botsglobal.logger.info(_('Writing to database is OK.'))


@django.db.transaction.commit_on_success # if no exception raised: commit, else rollback.
@django.db.transaction.atomic # if no exception raised: commit, else rollback.
def read_plugin(pathzipfile):
''' process uploaded plugin. '''
#test if valid zipfile
Expand Down
74 changes: 37 additions & 37 deletions src/bots/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-

from __future__ import unicode_literals
from django.conf.urls import patterns, include, url
from django.conf.urls import include
from django.contrib import auth
from django.urls import path
from django.contrib import admin
from django.contrib.auth.decorators import login_required, user_passes_test
from . import views
Expand All @@ -14,40 +16,38 @@

run_permission = user_passes_test(lambda u: u.has_perm('bots.change_mutex'))

urlpatterns = patterns(
'',
url(r'^login.*', 'django.contrib.auth.views.login', {'template_name': 'admin/login.html'}),
url(r'^logout.*', 'django.contrib.auth.views.logout', {'next_page': '/'}),
url(r'^password_change/$', 'django.contrib.auth.views.password_change', name='password_change'),
url(r'^password_change/done/$', 'django.contrib.auth.views.password_change_done',
name='password_change_done'),
#login required
url(r'^home.*', login_required(views.home)),
url(r'^incoming.*', login_required(views.incoming)),
url(r'^detail.*', login_required(views.detail)),
url(r'^process.*', login_required(views.process)),
url(r'^outgoing.*', login_required(views.outgoing)),
url(r'^document.*', login_required(views.document)),
url(r'^reports.*', login_required(views.reports)),
url(r'^confirm.*', login_required(views.confirm)),
url(r'^filer.*', login_required(views.filer)),
url(r'^srcfiler.*', login_required(views.srcfiler)),
url(r'^logfiler.*', login_required(views.logfiler)),
#only staff
url(r'^admin/$', login_required(views.home)), # do not show django admin root page
url(r'^admin/bots/$', login_required(views.home)), # do not show django admin root page
url(r'^admin/', include(admin.site.urls)),
url(r'^runengine.+', run_permission(views.runengine)),
#only superuser
url(r'^delete.*', superuser_required(views.delete)),
url(r'^plugin/index.*', superuser_required(views.plugin_index)),
url(r'^plugin.*', superuser_required(views.plugin)),
url(r'^plugout/index.*', superuser_required(views.plugout_index)),
url(r'^plugout/backup.*', superuser_required(views.plugout_backup)),
url(r'^plugout.*', superuser_required(views.plugout)),
url(r'^sendtestmail.*', superuser_required(views.sendtestmailmanagers)),
#catch-all
url(r'^.*', 'bots.views.index'),
)
urlpatterns = [
path(r'^login.*', auth.login, {'template_name': 'admin/login.html'}),
path(r'^logout.*', auth.logout, {'next_page': '/'}),
# path(r'^password_change/$', auth., name='password_change'),
# path(r'^password_change/done/$', auth.views.password_change_done, name='password_change_done'),
# login required
path(r'^home.*', login_required(views.home)),
path(r'^incoming.*', login_required(views.incoming)),
path(r'^detail.*', login_required(views.detail)),
path(r'^process.*', login_required(views.process)),
path(r'^outgoing.*', login_required(views.outgoing)),
path(r'^document.*', login_required(views.document)),
path(r'^reports.*', login_required(views.reports)),
path(r'^confirm.*', login_required(views.confirm)),
path(r'^filer.*', login_required(views.filer)),
path(r'^srcfiler.*', login_required(views.srcfiler)),
path(r'^logfiler.*', login_required(views.logfiler)),
# only staff
path(r'^admin/$', login_required(views.home)), # do not show django admin root page
path(r'^admin/bots/$', login_required(views.home)), # do not show django admin root page
path(r'^admin/', include(admin.site.paths)),
path(r'^runengine.+', run_permission(views.runengine)),
# only superuser
path(r'^delete.*', superuser_required(views.delete)),
path(r'^plugin/index.*', superuser_required(views.plugin_index)),
path(r'^plugin.*', superuser_required(views.plugin)),
path(r'^plugout/index.*', superuser_required(views.plugout_index)),
path(r'^plugout/backup.*', superuser_required(views.plugout_backup)),
path(r'^plugout.*', superuser_required(views.plugout)),
path(r'^sendtestmail.*', superuser_required(views.sendtestmailmanagers)),
# catch-all
path(r'^.*', views.index),
]

handler500 = 'bots.views.server_error'
handler500 = views.server_error