Skip to content

Commit

Permalink
Merge pull request #19 from bepatient-fr/feature_python3
Browse files Browse the repository at this point in the history
Feature python3
  • Loading branch information
M3te0r authored Apr 25, 2022
2 parents 9bca3e8 + ee01810 commit f148e3d
Show file tree
Hide file tree
Showing 73 changed files with 1,376 additions and 6,705 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ test/demo.hforge.org/
*.xhtml.ca
*.xhtml.nl_BE
ikaaro/ui_dev/aruni/node_modules/
.idea
File renamed without changes.
15 changes: 9 additions & 6 deletions ikaaro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@
from itools.gettext import register_domain

# Import from ikaaro
from file import File
from folder import Folder
from registry import register_document_type
import text
from webpage import WebPage
# Add class to register
from .root import Root
from .file import File
from .folder import Folder
from .registry import register_document_type
from . import text
from .webpage import WebPage


getLogger("ikaaro").addHandler(NullHandler())
getLogger("ikaaro.web").addHandler(NullHandler())
Expand All @@ -56,7 +59,7 @@


# Import required modules
import users
from . import users

# Register the itools domain
path = get_abspath('locale')
Expand Down
14 changes: 7 additions & 7 deletions ikaaro/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
from ikaaro.urls import urlpattern

# Import from here
from views import Api_DocView, ApiStatus_View
from views import Api_LoginView
from views import ApiDevPanel_ResourceJSON, ApiDevPanel_ResourceRaw, ApiDevPanel_ResourceHistory
from views import ApiDevPanel_ClassidViewDetails, ApiDevPanel_ClassidViewList
from views import ApiDevPanel_Config, ApiDevPanel_Log
from views import ApiDevPanel_CatalogReindex, UUIDView
from views import ApiDevPanel_ServerView, ApiDevPanel_ServerStop
from .views import Api_DocView, ApiStatus_View
from .views import Api_LoginView
from .views import ApiDevPanel_ResourceJSON, ApiDevPanel_ResourceRaw, ApiDevPanel_ResourceHistory
from .views import ApiDevPanel_ClassidViewDetails, ApiDevPanel_ClassidViewList
from .views import ApiDevPanel_Config, ApiDevPanel_Log
from .views import ApiDevPanel_CatalogReindex, UUIDView
from .views import ApiDevPanel_ServerView, ApiDevPanel_ServerStop


urlpatterns = [
Expand Down
35 changes: 15 additions & 20 deletions ikaaro/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,9 @@ def get_namespace(self, resource, context):
'methods': view.known_methods,
'description': view.__doc__}
namespace['endpoints'].append(kw)
i +=1
i += 1
return namespace


def get_view_query_as_list(self, view, schema):
l = []
for key, field in schema.items():
Expand All @@ -74,23 +73,19 @@ def get_view_query_as_list(self, view, schema):
return l




class Api_View(ItoolsView):

response_schema = {}
route = None
use_cookies = False


@classmethod
def get_route(cls):
"""
:return: The route associated to the class
"""
return cls.route


def get_resource(self, context):
return context.resource

Expand Down Expand Up @@ -126,7 +121,7 @@ class UUIDView(Api_View):
access = True
known_methods = ['DELETE']

path_query_schema = {'uuid': Char_Field(title=MSG(u'The uuid of a resource in DB'))}
path_query_schema = {'uuid': Char_Field(title=MSG('The uuid of a resource in DB'))}

def get_resource(self, context):
query = get_resource_by_uuid_query(
Expand All @@ -143,7 +138,7 @@ def get_resource(self, context):
# Forbidden (403)
raise Forbidden
raise NotFound
return search.get_resources(size=1).next()
return next(search.get_resources(size=1))


access_DELETE = 'is_allowed_to_remove'
Expand All @@ -160,7 +155,7 @@ class ApiDevPanel_ResourceJSON(UUIDView):

access = 'is_admin'
known_methods = ['GET', 'DELETE']
query_schema = {'pretty': Boolean_Field(title=MSG(u'Pretty ?'))}
query_schema = {'pretty': Boolean_Field(title=MSG('Pretty ?'))}

def GET(self, root, context):
resource = self.get_resource(context)
Expand Down Expand Up @@ -195,10 +190,10 @@ class ApiDevPanel_ResourceHistory(UUIDView):
access = 'is_admin'
known_methods = ['GET', 'DELETE']
response_schema = {
'sha': Char_Field(title=MSG(u'SHA of the commit')),
'sha': Char_Field(title=MSG('SHA of the commit')),
'author_date': Datetime_Field(title=MSG("Datetime of commit")),
'author_name': Char_Field(title=MSG(u"Commit's author name")),
'message_short': Char_Field(title=MSG(u"Commit's title"))
'author_name': Char_Field(title=MSG("Commit's author name")),
'message_short': Char_Field(title=MSG("Commit's title"))
}
def GET(self, root, context):
resource = self.get_resource(context)
Expand Down Expand Up @@ -230,11 +225,11 @@ class ApiDevPanel_ClassidViewDetails(Api_View):
access = 'is_admin'

path_query_schema = {
'class_id': Char_Field(title=MSG(u'A class_id registered in DB'))
'class_id': Char_Field(title=MSG('A class_id registered in DB'))
}
response_schema = {
'class_title': Char_Field(title=MSG(u'The class_title of the resource cls')),
'class_id': Char_Field(title=MSG(u'The class_id of the resource cls'))
'class_title': Char_Field(title=MSG('The class_title of the resource cls')),
'class_id': Char_Field(title=MSG('The class_id of the resource cls'))
}


Expand Down Expand Up @@ -265,8 +260,8 @@ class Api_LoginView(Api_View):

access = True
known_methods = ['POST']
schema = {'email': Email_Field(title=MSG(u'Username'), required=True),
'password': Password_Field(title=MSG(u'Password'), required=True)}
schema = {'email': Email_Field(title=MSG('Username'), required=True),
'password': Password_Field(title=MSG('Password'), required=True)}

def POST(self, root, context):
raise NotImplementedError
Expand Down Expand Up @@ -317,9 +312,9 @@ class ApiDevPanel_ServerView(Api_View):
access = 'is_admin'
known_methods = ['GET']
response_schema = {
'timestamp': Char_Field(title=MSG(u"Server's start timestamp")),
'pid': Integer_Field(title=MSG(u"Server's PID")),
'port': Integer_Field(title=MSG(u"Server's port"))
'timestamp': Char_Field(title=MSG("Server's start timestamp")),
'pid': Integer_Field(title=MSG("Server's PID")),
'port': Integer_Field(title=MSG("Server's port"))
}

def GET(self, root, context):
Expand Down
28 changes: 14 additions & 14 deletions ikaaro/autoadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
from itools.web import get_context, ERROR, FormError

# Import from ikaaro
from autoform import AutoForm
from datatypes import BirthDate
from datatypes import Days, Months, Years
from buttons import Button
from fields import Field
import messages
from widgets import HiddenWidget, ReadOnlyWidget
from .autoform import AutoForm
from .datatypes import BirthDate
from .datatypes import Days, Months, Years
from .buttons import Button
from .fields import Field
from . import messages
from .widgets import HiddenWidget, ReadOnlyWidget



Expand All @@ -37,7 +37,7 @@ class AutoAdd(AutoForm):

access = 'is_allowed_to_add'

actions = [Button(access=True, css='btn btn-primary', title=MSG(u'Add'))]
actions = [Button(access=True, css='btn btn-primary', title=MSG('Add'))]
action_goto = None
goto_view = None
goto_parent_view = None # DEPRECATED -> use action_goto
Expand Down Expand Up @@ -90,10 +90,10 @@ def get_title(self, context):
cls = self._resource_class
if cls:
class_title = cls.class_title.gettext()
title = MSG(u'Add {class_title}')
title = MSG('Add {class_title}')
return title.gettext(class_title=class_title)

return MSG(u'Add resource').gettext()
return MSG('Add resource').gettext()


def _get_datatype(self, resource, context, name):
Expand Down Expand Up @@ -162,11 +162,11 @@ def get_value(self, resource, context, name, datatype):
# View cls_description
value = getattr(self, name, None)
if value is not None:
return value.gettext() if value else u''
return value.gettext() if value else ''
# Resource cls_description
cls = self._resource_class
value = cls.class_description
return value.gettext() if value else u''
return value.gettext() if value else ''
elif name == 'referrer':
referrer = context.query.get('referrer')
return referrer or context.get_referrer()
Expand All @@ -177,7 +177,7 @@ def get_value(self, resource, context, name, datatype):

if getattr(datatype, 'multilingual', False):
for language in resource.get_edit_languages(context):
value.setdefault(language, u'')
value.setdefault(language, '')

return value

Expand All @@ -196,7 +196,7 @@ def get_container(self, resource, context, form):
root = context.root
if not root.has_permission(context.user, 'add', container, class_id):
path = '/' if path == '.' else '/%s/' % path
msg = ERROR(u'Adding resources to {path} is not allowed.')
msg = ERROR('Adding resources to {path} is not allowed.')
raise FormError(msg.gettext(path=path))

# Ok
Expand Down
18 changes: 9 additions & 9 deletions ikaaro/autoedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@
from itools.web import get_context

# Import from ikaaro
from autoform import AutoForm
from widgets import HiddenWidget, timestamp_widget
from datatypes import BirthDate
from datatypes import Days, Months, Years
from fields import Field
import messages
from views import ContextMenu
from .autoform import AutoForm
from .widgets import HiddenWidget, timestamp_widget
from .datatypes import BirthDate
from .datatypes import Days, Months, Years
from .fields import Field
from . import messages
from .views import ContextMenu


class EditLanguageMenu(ContextMenu):

title = MSG(u'Configuration')
title = MSG('Configuration')
template = '/ui/ikaaro/generic/edit_language_menu.xml'
view = None

Expand Down Expand Up @@ -87,7 +87,7 @@ def display(self):
class AutoEdit(AutoForm):

access = 'is_allowed_to_edit'
title = MSG(u'Edit')
title = MSG('Edit')

fields = ['title', 'description', 'subject']
def get_fields(self):
Expand Down
12 changes: 6 additions & 6 deletions ikaaro/autoform.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
from itools.web import STLView

# Import from ikaaro
from buttons import Button
from datatypes import BirthDate
from datatypes import Days, Months, Years
from .buttons import Button
from .datatypes import BirthDate
from .datatypes import Days, Months, Years


###########################################################################
Expand All @@ -46,8 +46,8 @@ class AutoForm(STLView):
Widgets is a list:
[TextWidget('firstname', title=MSG(u'Firstname')),
TextWidget('lastname', title=MSG(u'Lastname'))]
[TextWidget('firstname', title=MSG('Firstname')),
TextWidget('lastname', title=MSG('Lastname'))]
"""

template = '/ui/ikaaro/auto_form.xml'
Expand All @@ -58,7 +58,7 @@ class AutoForm(STLView):
widgets = []
description = None
method = 'post'
actions = [Button(access=True, css='btn btn-success', title=MSG(u'Save'))]
actions = [Button(access=True, css='btn btn-success', title=MSG('Save'))]

def get_widgets(self, resource, context):
return self.widgets
Expand Down
Loading

0 comments on commit f148e3d

Please sign in to comment.