Skip to content
This repository was archived by the owner on Jun 20, 2021. It is now read-only.

Commit b9965c8

Browse files
author
regisf
committed
Reformat files
1 parent 4f92a4e commit b9965c8

24 files changed

+123
-140
lines changed

Application/App/Admin/codeshandler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
# along with this program; if not, write to the Free Software
1818
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1919

20-
from tornadoext.requesthandler import RequestHandler, admin_auth_required
21-
2220
from App.models.preference import Config
21+
from tornadoext.requesthandler import RequestHandler, admin_auth_required
2322

2423

2524
class CodesHandler(RequestHandler):
2625
"""
2726
Handle all codes for analytics or twitter,
2827
"""
28+
2929
@admin_auth_required
3030
def get(self):
3131
config = Config()
@@ -67,4 +67,4 @@ def post(self):
6767
self.settings['twitter_consumer_key'] = config.get('twitter_consumer_key')
6868
self.settings['twitter_consumer_secret'] = config.get('twitter_consumer_secret')
6969

70-
self.redirect('/admin/codes/')
70+
self.redirect('/admin/codes/')

Application/App/Admin/emailshandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
# along with this program; if not, write to the Free Software
1818
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1919

20-
from tornadoext.requesthandler import RequestHandler, admin_auth_required
2120
from App.models.email import EmailModel
2221
from App.models.preference import PreferenceModel
22+
from tornadoext.requesthandler import RequestHandler, admin_auth_required
2323

2424

2525
def control_arguments(handler, edit=False):

Application/App/Admin/mainhandler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
# along with this program; if not, write to the Free Software
1818
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1919

20+
from App.models.regex import RegexModel
21+
from App.models.user import UserModel
2022
from tornadoext.requesthandler import RequestHandler, admin_auth_required
2123

22-
from App.models.user import UserModel
23-
from App.models.regex import RegexModel
2424

2525
class AdminHandler(RequestHandler):
2626
@admin_auth_required

Application/App/Admin/preferencehandler.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
# along with this program; if not, write to the Free Software
1818
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1919

20-
from tornadoext.requesthandler import RequestHandler, admin_auth_required
21-
2220
from App.models.preference import PreferenceModel
21+
from tornadoext.requesthandler import RequestHandler, admin_auth_required
2322

2423

2524
class PreferenceHandler(RequestHandler):
@@ -35,4 +34,3 @@ def post(self):
3534
server_password = self.get_argument("serverpassword", "")
3635
PreferenceModel().save_mail_server(default_email, server_name, server_port, server_username, server_password)
3736
self.redirect("/admin/emails/")
38-

Application/App/Admin/urls.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323

2424
__author__ = 'Regis FLORET'
2525

26-
from App.Admin.mainhandler import AdminHandler, LoginHandler, LogoutHandler
27-
from App.Admin.usershandler import UsersHandler, UsersEditHandler, UsersDeleteHandler, UsersAddHandler
26+
from App.Admin.codeshandler import CodesHandler
2827
from App.Admin.emailshandler import EmailsHandler, EmailsAddHandler, EmailsDeleteHandler, EmailEditHandler
28+
from App.Admin.mainhandler import AdminHandler, LoginHandler, LogoutHandler
2929
from App.Admin.preferencehandler import PreferenceHandler
30-
from App.Admin.codeshandler import CodesHandler
30+
from App.Admin.usershandler import UsersHandler, UsersEditHandler, UsersDeleteHandler, UsersAddHandler
3131

3232
URLS = [
3333
(r'^/admin/$', AdminHandler),
@@ -47,5 +47,3 @@
4747

4848
(r'/admin/codes/$', CodesHandler),
4949
]
50-
51-

Application/App/Admin/usershandler.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
# along with this program; if not, write to the Free Software
1818
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1919

20-
from tornadoext.requesthandler import RequestHandler, admin_auth_required
21-
2220
from App.models.user import UserModel
21+
from tornadoext.requesthandler import RequestHandler, admin_auth_required
2322

2423

2524
class UsersHandler(RequestHandler):
@@ -73,7 +72,7 @@ def post(self, name):
7372
"""
7473
Execution page
7574
"""
76-
#TODO: Test if the user to delete is not the user and not the last admin
75+
# TODO: Test if the user to delete is not the user and not the last admin
7776
UserModel().delete(name)
7877
self.redirect('/admin/users/')
7978

@@ -82,6 +81,7 @@ class UsersAddHandler(RequestHandler):
8281
"""
8382
Add a new user
8483
"""
84+
8585
@admin_auth_required
8686
def get(self):
8787
self.render('admin/users/add.html', errors={})
@@ -92,33 +92,23 @@ def post(self):
9292
The user is created
9393
"""
9494
errors = {}
95-
user_model = UserModel()
9695

9796
username = self.get_argument('username')
9897
email = self.get_argument('email')
9998
password = self.get_argument('password')
100-
confirm = self.get_argument('confirm')
10199
is_admin = self.get_argument('is_admin', 'off') == 'on'
102100

103101
if not email:
104102
errors['email'] = 'An email address is required'
105103

106104
if not username:
107105
errors['username'] = 'Username cannot be empty'
108-
# elif user_model.exists(username):
109-
# errors['username'] = 'User name exists'
110106

111107
if not password:
112108
errors['password'] = 'Password is empty'
113109

114-
# if password and (password != confirm):
115-
# errors['password'] = 'Password and its confirmation are different'
116-
117-
add_another = 'add_another' in self.request.arguments
118-
continue_edit = 'continue_edit' in self.request.arguments
119-
120110
if errors.keys():
121111
self.render('admin/users/add.html', errors=errors)
122112

123113
UserModel().create_user(username, email, password, is_admin=is_admin)
124-
self.redirect('/admin/users/')
114+
self.redirect('/admin/users/')

Application/App/Home/ajaxhandler.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@
2424

2525
print("Restart")
2626

27+
2728
class AjaxHandler(tornado.web.RequestHandler, PyRegex):
2829
def get(self):
2930
if self.request.headers.get('X-Requested-With') == 'XMLHttpRequest':
3031
try:
3132
value = json.loads(self.get_argument('json', None))
3233
print(value)
33-
self.write(self.doTheJob(value))
34+
self.write(self.do_the_job(value))
3435
except TypeError as e:
3536
self.write(json.dumps({'success': False, 'error': e}))

Application/App/Home/connecthandler.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# -*- coding: utf-8 -*-
32
#
43
# Python-regex.com : Regular expression as in Kodos3 but for the web
@@ -18,19 +17,18 @@
1817
# along with this program; if not, write to the Free Software
1918
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2019

21-
import json
2220
import binascii
21+
import json
2322
import os
2423

25-
from tornado.web import authenticated, HTTPError
2624
from tornado.auth import GoogleOAuth2Mixin, TwitterMixin, FacebookGraphMixin
2725
from tornado.gen import coroutine
26+
from tornado.web import authenticated, HTTPError
2827

29-
from tornadoext.requesthandler import RequestHandler
30-
from tornadoext.oauth import GithubMixin, LinkedInMixin
31-
32-
from App.models.user import UserModel
3328
from App.models.preference import Config
29+
from App.models.user import UserModel
30+
from tornadoext.oauth import GithubMixin, LinkedInMixin
31+
from tornadoext.requesthandler import RequestHandler
3432

3533

3634
class LoginHandler(RequestHandler):
@@ -59,6 +57,7 @@ class LogoutHandler(RequestHandler):
5957
"""
6058
Disconnect the user and go to the main page
6159
"""
60+
6261
@authenticated
6362
def get(self):
6463
self.add_flash_message(0, "You are now disconnected.")
@@ -70,6 +69,7 @@ class GoogleOAuth2Handler(RequestHandler, GoogleOAuth2Mixin):
7069
"""
7170
Connect with Google account
7271
"""
72+
7373
@coroutine
7474
def get(self, *args, **kwargs):
7575
redirect_uri = "%s://%s" % (self.request.protocol, "python-regex.com/auth/google/")
@@ -84,7 +84,7 @@ def get(self, *args, **kwargs):
8484
redirect_uri=redirect_uri,
8585
code=self.get_argument('code')
8686
)
87-
87+
8888
access_token = str(user['access_token'])
8989
http_client = self.get_auth_http_client()
9090
response = yield http_client.fetch('https://www.googleapis.com/oauth2/v1/userinfo?access_token={}'
@@ -118,6 +118,7 @@ class TwitterOAuth2Handler(RequestHandler, TwitterMixin):
118118
"""
119119
Connect with Twitter account
120120
"""
121+
121122
@coroutine
122123
def get(self, *args, **kwargs):
123124
if self.get_argument("oauth_token", None):
@@ -157,10 +158,12 @@ def get(self):
157158
extra_params={"scope": "read_stream,offline_access"}
158159
)
159160

161+
160162
class LinkedInOAuth2Handler(RequestHandler, LinkedInMixin):
161163
"""
162164
Connect with LinkedIn API
163165
"""
166+
164167
@coroutine
165168
def get(self, *args, **kwargs):
166169
config = Config()
@@ -203,11 +206,11 @@ def get(self, *args, **kwargs):
203206
print(user_data)
204207

205208

206-
207209
class GithubOAuth2Handler(RequestHandler, GithubMixin):
208210
"""
209211
Connect with GitHub API
210212
"""
213+
211214
@coroutine
212215
def get(self, *args, **kwargs):
213216
redirect_uri = '/auth/github/'
@@ -232,4 +235,4 @@ def get(self, *args, **kwargs):
232235
)
233236

234237
def _on_login(self, user):
235-
print(user)
238+
print(user)

Application/App/Home/contacthandler.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,21 @@
1717
# along with this program; if not, write to the Free Software
1818
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1919

20-
import re
21-
2220
from tornado.web import RequestHandler
23-
from App.utils.email import send_mail
21+
22+
import private_settings
2423
from App.models.email import EmailModel
2524
from App.models.preference import PreferenceModel
25+
from App.utils.email import send_mail
2626
from App.utils.template import micro_template
2727

28-
import private_settings
29-
3028

3129
class ContactHandler(RequestHandler):
3230
"""
3331
Send an email via the contact form
3432
FIXME: This might be async
3533
"""
34+
3635
def post(self):
3736
"""
3837
Manage post
@@ -65,5 +64,3 @@ def post(self):
6564
self.write("ok")
6665
except Exception as e:
6766
self.write("error: " + str(e))
68-
69-

Application/App/Home/homehandler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
from tornadoext.requesthandler import RequestHandler
2323

24+
2425
class HomeHandler(RequestHandler):
2526
def get(self):
2627
msie = re.findall(r'MSIE\s(\d+)', self.request.headers.get('user-agent'))

0 commit comments

Comments
 (0)