Skip to content

Commit

Permalink
chore: fix dependencies. (#2045)
Browse files Browse the repository at this point in the history
* chore: fix dependencies.

* chore: update dependencies.

* chore: remove PyGobject

* chore: fix dependencies.

* chore: pin werkzeug version.

* chore: pin wtforms version.

* chore: pin versions.

* chore: remove CSRF check.

* chore: fix dependencies
  • Loading branch information
teleyinex committed Jun 23, 2022
1 parent fd87953 commit d6409ee
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 149 deletions.
10 changes: 5 additions & 5 deletions pybossa/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,11 +561,11 @@ def _global_template_context():
plugins=plugins,
ldap_enabled=ldap_enabled)

@csrf.error_handler
def csrf_error_handler(reason):
response = dict(template='400.html', code=400,
description=reason)
return handle_content_type(response)
# @csrf.error_handler
# def csrf_error_handler(reason):
# response = dict(template='400.html', code=400,
# description=reason)
# return handle_content_type(response)


def setup_jinja2_filters(app):
Expand Down
93 changes: 60 additions & 33 deletions pybossa/repositories/project_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,24 @@ def get_by(self, **attributes):
def get_all(self):
return self.db.session.query(Project).all()

def filter_by(self, limit=None, offset=0, yielded=False, last_id=None,
fulltextsearch=None, desc=False, **filters):
if filters.get('owner_id'):
filters['owner_id'] = filters.get('owner_id')
return self._filter_by(Project, limit, offset, yielded, last_id,
fulltextsearch, desc, **filters)
def filter_by(
self,
limit=None,
offset=0,
yielded=False,
last_id=None,
fulltextsearch=None,
desc=False,
**filters
):
if filters.get("owner_id"):
filters["owner_id"] = filters.get("owner_id")
return self._filter_by(
Project, limit, offset, yielded, last_id, fulltextsearch, desc, **filters
)

def save(self, project):
self._validate_can_be('saved', project)
self._validate_can_be("saved", project)
self._empty_strings_to_none(project)
self._creator_is_owner(project)
try:
Expand All @@ -61,25 +70,26 @@ def save(self, project):
raise DBIntegrityError(e)

def update(self, project):
self._validate_can_be('updated', project)
self._empty_strings_to_none(project)
self._creator_is_owner(project)
try:
self._validate_can_be("updated", project)
self._empty_strings_to_none(project)
self._creator_is_owner(project)
self.db.session.merge(project)
self.db.session.commit()
except IntegrityError as e:
self.db.session.rollback()
raise DBIntegrityError(e)

def delete(self, project):
self._validate_can_be('deleted', project)
project = self.db.session.query(Project).filter(Project.id==project.id).first()
self._validate_can_be("deleted", project)
project = (
self.db.session.query(Project).filter(Project.id == project.id).first()
)
self.db.session.delete(project)
self.db.session.commit()
cached_projects.clean(project.id)
self._delete_zip_files_from_store(project)


# Methods for Category objects
def get_category(self, id=None):
if id is None:
Expand All @@ -92,17 +102,33 @@ def get_category_by(self, **attributes):
def get_all_categories(self):
return self.db.session.query(Category).all()

def filter_categories_by(self, limit=None, offset=0, yielded=False,
last_id=None, fulltextsearch=None,
orderby='id',
desc=False, **filters):
if filters.get('owner_id'):
del filters['owner_id']
return self._filter_by(Category, limit, offset, yielded, last_id,
fulltextsearch, desc, orderby, **filters)
def filter_categories_by(
self,
limit=None,
offset=0,
yielded=False,
last_id=None,
fulltextsearch=None,
orderby="id",
desc=False,
**filters
):
if filters.get("owner_id"):
del filters["owner_id"]
return self._filter_by(
Category,
limit,
offset,
yielded,
last_id,
fulltextsearch,
desc,
orderby,
**filters
)

def save_category(self, category):
self._validate_can_be('saved as a Category', category, klass=Category)
self._validate_can_be("saved as a Category", category, klass=Category)
try:
self.db.session.add(category)
self.db.session.commit()
Expand All @@ -111,7 +137,7 @@ def save_category(self, category):
raise DBIntegrityError(e)

def update_category(self, new_category, caller="web"):
self._validate_can_be('updated as a Category', new_category, klass=Category)
self._validate_can_be("updated as a Category", new_category, klass=Category)
try:
self.db.session.merge(new_category)
self.db.session.commit()
Expand All @@ -120,16 +146,16 @@ def update_category(self, new_category, caller="web"):
raise DBIntegrityError(e)

def delete_category(self, category):
self._validate_can_be('deleted as a Category', category, klass=Category)
self.db.session.query(Category).filter(Category.id==category.id).delete()
self._validate_can_be("deleted as a Category", category, klass=Category)
self.db.session.query(Category).filter(Category.id == category.id).delete()
self.db.session.commit()

def _empty_strings_to_none(self, project):
if project.name == '':
if project.name == "":
project.name = None
if project.short_name == '':
if project.short_name == "":
project.short_name = None
if project.description == '':
if project.description == "":
project.description = None

def _creator_is_owner(self, project):
Expand All @@ -141,18 +167,19 @@ def _creator_is_owner(self, project):
def _validate_can_be(self, action, element, klass=Project):
if not isinstance(element, klass):
name = element.__class__.__name__
msg = '%s cannot be %s by %s' % (name, action, self.__class__.__name__)
msg = "%s cannot be %s by %s" % (name, action, self.__class__.__name__)
raise WrongObjectError(msg)

def _delete_zip_files_from_store(self, project):
from pybossa.core import json_exporter, csv_exporter

global uploader
if uploader is None:
from pybossa.core import uploader
json_tasks_filename = json_exporter.download_name(project, 'task')
csv_tasks_filename = csv_exporter.download_name(project, 'task')
json_taskruns_filename = json_exporter.download_name(project, 'task_run')
csv_taskruns_filename = csv_exporter.download_name(project, 'task_run')
json_tasks_filename = json_exporter.download_name(project, "task")
csv_tasks_filename = csv_exporter.download_name(project, "task")
json_taskruns_filename = json_exporter.download_name(project, "task_run")
csv_taskruns_filename = csv_exporter.download_name(project, "task_run")
container = "user_%s" % project.owner_id
uploader.delete_file(json_tasks_filename, container)
uploader.delete_file(csv_tasks_filename, container)
Expand Down
56 changes: 28 additions & 28 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

with open('pybossa/version.txt') as f:
with open("pybossa/version.txt") as f:
version = f.readline()
__version__ = version.rstrip()

Expand All @@ -14,7 +14,7 @@
"certifi==2018.11.29",
"cffi>=1.11.5",
"chardet==3.0.4",
"Click==7.0",
"Click==8.0.3",
"colorama==0.4.1",
"cov-core==1.15.0",
"coverage==4.5.2",
Expand All @@ -27,7 +27,7 @@
"factory-boy==2.4.1",
"Faker==1.0.1",
"feedparser==5.2.1",
"Flask",
"Flask==1.1.2",
"Flask-Assets==0.12",
"Flask-Babel>=0.9",
"Flask-Cors>=3.0.2",
Expand All @@ -40,8 +40,8 @@
"Flask-Plugins>=1.6.1",
"flask-profiler==1.6",
"Flask-SimpleLDAP>=1.1.2",
"Flask-SQLAlchemy>=2.3.2",
"Flask-WTF>=0.9.5",
"Flask-SQLAlchemy==2.4.4",
"Flask-WTF==0.14.3",
"flatten-json==0.1.6",
"google-api-python-client==1.5.5",
"html2text==2014.7.3",
Expand All @@ -54,7 +54,7 @@
"iso8601==0.1.12",
"itsdangerous==1.1.0",
"jeepney==0.4",
"Jinja2>=2.10.1",
"Jinja2==2.11.2",
"jsmin==2.2.2",
"keyring==17.1.1",
"keystoneauth1==3.11.2",
Expand Down Expand Up @@ -95,7 +95,7 @@
"PyLD==1.0.4",
"pyldap==3.0.0.post1",
"pyOpenSSL==18.0.0",
"pyparsing==2.3.0",
"pyparsing==2.4.7",
"python-dateutil==2.7.5",
"python-editor==1.0.3",
"python-keystoneclient==3.18.0",
Expand Down Expand Up @@ -132,16 +132,16 @@
"urllib3==1.24.2",
"validators==0.12.6",
"webassets==0.12.1",
"Werkzeug",
"Werkzeug==1.0.1",
"wrapt==1.10.11",
"WTForms>=1.0.5",
"WTForms-Components>=0.10.3",
"WTForms==2.3.3",
"WTForms-Components==0.10.5",
"yacryptopan==1.0.0",
"email_validator==1.1.1"
"email_validator==1.1.1",
]

setup(
name='pybossa',
name="pybossa",
version=__version__,
packages=find_packages(),
install_requires=requirements,
Expand All @@ -153,23 +153,23 @@
# '[email protected]:Scifabric/pybossa.git@b8ab2ef199e82ca417d470bbed916c7b8dbda4d4#egg=pybossa'
# ]
# metadata for upload to PyPI
author='Scifabric LTD',
author_email='[email protected]',
description='Open Source CrowdSourcing framework',
long_description='''PYBOSSA is the ultimate crowdsourcing framework to analyze or enrich data that can't be processed by machines alone.''',
license='AGPLv3',
url='http://pybossa.com',
download_url='https://github.com/Scifabric/pybossa',
author="Scifabric LTD",
author_email="[email protected]",
description="Open Source CrowdSourcing framework",
long_description="""PYBOSSA is the ultimate crowdsourcing framework to analyze or enrich data that can't be processed by machines alone.""",
license="AGPLv3",
url="http://pybossa.com",
download_url="https://github.com/Scifabric/pybossa",
include_package_data=True,
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU Affero v3',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Software Development :: Libraries :: Python Modules'
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Affero v3",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Topic :: Software Development :: Libraries :: Python Modules",
],
entry_points='''
'''
entry_points="""
""",
)
Loading

0 comments on commit d6409ee

Please sign in to comment.