Skip to content

Commit

Permalink
flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
Zharktas committed Mar 9, 2015
1 parent b24706c commit 39ad7f2
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 35 deletions.
10 changes: 1 addition & 9 deletions modules/ckanext-ytp-comments/ckanext/ytp/comments/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def edit(self, dataset_id, comment_id):
except:
abort(403)

errors = {}
if request.method == 'POST':
data_dict = clean_dict(unflatten(
tuplize_dict(parse_params(request.POST))))
Expand All @@ -39,7 +38,6 @@ def edit(self, dataset_id, comment_id):
res = get_action('comment_update')(context, data_dict)
success = True
except ValidationError, ve:
errors = ve.error_dict
log.debug(ve)
except Exception, e:
log.debug(e)
Expand All @@ -48,7 +46,6 @@ def edit(self, dataset_id, comment_id):
if success:
h.redirect_to(str('/dataset/%s#comment_%s' % (c.pkg.name, res['id'])))

vars = {'errors': errors}
return render("package/read.html")

def reply(self, dataset_id, parent_id):
Expand Down Expand Up @@ -81,7 +78,6 @@ def _add_or_reply(self, dataset_id):
except:
abort(403)

errors = {}
if request.method == 'POST':
data_dict = clean_dict(unflatten(
tuplize_dict(parse_params(request.POST))))
Expand All @@ -92,7 +88,6 @@ def _add_or_reply(self, dataset_id):
res = get_action('comment_create')(context, data_dict)
success = True
except ValidationError, ve:
errors = ve.error_dict
log.debug(ve)
except Exception, e:
log.debug(e)
Expand All @@ -101,7 +96,6 @@ def _add_or_reply(self, dataset_id):
if success:
h.redirect_to(str('/dataset/%s#comment_%s' % (c.pkg.name, res['id'])))

vars = {'errors': errors}
return render("package/read.html")

def delete(self, dataset_id, comment_id):
Expand All @@ -119,14 +113,12 @@ def delete(self, dataset_id, comment_id):
except:
abort(403)

errors = {}
try:
data_dict = {'id': comment_id}
res = get_action('comment_delete')(context, data_dict)
get_action('comment_delete')(context, data_dict)
except Exception, e:
log.debug(e)

h.redirect_to(str('/dataset/%s' % c.pkg.name))

vars = {'errors': errors}
return render("package/read.html")
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import create
import get
import update
import delete
# this is a namespace package
try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

def comment_delete(context, data_dict):
model = context['model']
user = context['user']

logic.check_access("comment_delete", context, data_dict)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def thread_show(context, data_dict):
"""

model = context['model']
user = context['user']

url = data_dict.get('url')
id = data_dict.get('id')
Expand Down Expand Up @@ -73,8 +72,6 @@ def thread_show(context, data_dict):


def comment_show(context, data_dict):
model = context['model']
user = context['user']
id = logic.get_or_bust(data_dict, 'id')
comment = comment_model.Comment.get(id)
if not comment:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

def comment_update(context, data_dict):
model = context['model']
user = context['user']

logic.check_access("comment_update", context, data_dict)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import create
import update
import get
import delete
# this is a namespace package
try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
2 changes: 1 addition & 1 deletion modules/ckanext-ytp-comments/ckanext/ytp/comments/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from sqlalchemy.ext.declarative import declarative_base

from ckan.plugins import toolkit
from ckan.lib.base import *
from ckan.lib.base import model, config

log = __import__('logging').getLogger(__name__)

Expand Down
24 changes: 13 additions & 11 deletions modules/ckanext-ytp-comments/ckanext/ytp/comments/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,24 @@ def get_helpers(self):
}

def get_actions(self):
import ckanext.ytp.comments.logic.action as actions
from ckanext.ytp.comments.logic.action import get, create, delete, update

return {
"comment_create": actions.create.comment_create,
"thread_show": actions.get.thread_show,
"comment_update": actions.update.comment_update,
"comment_show": actions.get.comment_show,
"comment_delete": actions.delete.comment_delete
"comment_create": create.comment_create,
"thread_show": get.thread_show,
"comment_update": update.comment_update,
"comment_show": get.comment_show,
"comment_delete": delete.comment_delete
}

def get_auth_functions(self):
import ckanext.ytp.comments.logic.auth as auths
from ckanext.ytp.comments.logic.auth import get, create, delete, update

return {
'comment_create': auths.create.comment_create,
'comment_update': auths.update.comment_update,
'comment_show': auths.get.comment_show,
'comment_delete': auths.delete.comment_delete
'comment_create': create.comment_create,
'comment_update': update.comment_update,
'comment_show': get.comment_show,
'comment_delete': delete.comment_delete
}
# IPackageController

Expand Down
3 changes: 2 additions & 1 deletion modules/ckanext-ytp-main/ckanext/ytp/user/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
unflatten = dictization_functions.unflatten
DataError = dictization_functions.DataError


class YtpUserController(UserController):

# Modify original CKAN Edit user controller
Expand Down Expand Up @@ -159,7 +160,7 @@ def _save_edit(self, id, context):
if 'activity_streams_email_notifications' not in data_dict:
data_dict['activity_streams_email_notifications'] = False

user = get_action('user_update')(context, data_dict)
get_action('user_update')(context, data_dict)
h.flash_success(_('Profile updated'))
h.redirect_to('home')
except NotAuthorized:
Expand Down

0 comments on commit 39ad7f2

Please sign in to comment.