Module collectives.api
Contents
Module collectives.api
#
API of collectives
website.
This is a very simple API meant to be used with Ajax frontend, mainly
Tabulator . It offers GET
endpoint to
serve various tables dynamically.
But it could be extended to POST
and DELETE
request later.
This module is initialized by the application factory, and contains the
/api
blueprint.
Module collectives.api.common
#
API submodule for the blueprint
Typical usage example:
from . import api
app = Flask(__name__)
app.register_blueprint(api.blueprint)
- collectives.api.common.avatar_url(user)#
Get avatar URL for a user.
- Parameters
user (
collectives.models.user.User
) – the user from which avatar is wanted.- Returns
A URL to a resized picture of the avatar 30x30. If user has no avatar it returns the default avatar SVG.
- collectives.api.common.blueprint = <Blueprint 'api'>#
The blueprint for the API.
- Type
flask.Blueprint
- collectives.api.common.marshmallow = <flask_marshmallow.Marshmallow object>#
Marshmallow object.
- Type
flask_marshmallow.Marshmallow
Module collectives.api.admin
#
API for user list in administration page.
- class collectives.api.admin.AdminUserSchema(*args, **kwargs)#
Schema for users in admin list
- class Meta#
Fields to expose
- badges_uri#
URI to badge management page for this user
- Type
string
- delete_uri#
URI to delete this user (WIP)
- Type
string
- manage_uri#
URI to modify this user
- Type
string
- opts: LoadInstanceMixin.Opts = <flask_marshmallow.sqla.SQLAlchemyAutoSchemaOpts object>#
- roles_uri#
URI to role management page for this user
- Type
string
- class collectives.api.admin.LeaderRoleSchema(*args, **kwargs)#
Schema for a leader role
Combines a
UserSchema
andevent.ActivityTypeSchema
.- class Meta#
Fields to expose
- opts: LoadInstanceMixin.Opts = <flask_marshmallow.sqla.SQLAlchemyAutoSchemaOpts object>#
- class collectives.api.admin.UserBadgeSchema(*args, **kwargs)#
Schema for a badge
Combines a
UserSchema
andevent.ActivityTypeSchema
.- class Meta#
Fields to expose
- opts: LoadInstanceMixin.Opts = <flask_marshmallow.sqla.SQLAlchemyAutoSchemaOpts object>#
- collectives.api.admin.badges()#
API endpoint to list current badges
Only available to administrators and activity supervisors
- Returns
A tuple:
JSON containing information describe in UserSchema
HTTP return code : 200
additional header (content as JSON)
- Return type
(string, int, dict)
- collectives.api.admin.leaders()#
API endpoint to list current leaders
Only available to administrators and activity supervisors
- Returns
A tuple:
JSON containing information describe in UserSchema
HTTP return code : 200
additional header (content as JSON)
- Return type
(string, int, dict)
- collectives.api.admin.users()#
API endpoint to list users
Only available to administrators
- Returns
A tuple:
JSON containing information describe in AdminUserSchema
HTTP return code : 200
additional header (content as JSON)
- Return type
(string, int, dict)
Module collectives.api.autocomplete_user
#
API for autocomplete users name.
Especially used for user registration by leader in events.
- class collectives.api.autocomplete_user.AutocompleteUserSchema(*args, **kwargs)#
Schema under which autocomplete suggestions are returned
- class Meta#
Fields to expose
- opts: LoadInstanceMixin.Opts = <flask_marshmallow.sqla.SQLAlchemyAutoSchemaOpts object>#
- collectives.api.autocomplete_user.autocomplete_available_leaders()#
API endpoint to list available leaders for autocomplete. In contrast with the previous function this also includes leaders that have never led any event.
At least 2 characters are required to make a name search.
- Parameters
q (string) – Search string.
l (int) – Maximum number of returned items.
aid (list[int]) – List of activity ids to include. Empty means include leaders of any activity
eid (list[int]) – List of leader ids to exclude
etype (int) – Id of event type
- Returns
A tuple:
JSON containing information describe in AutocompleteUserSchema
HTTP return code : 200
additional header (content as JSON)
- Return type
(string, int, dict)
- collectives.api.autocomplete_user.autocomplete_leaders()#
API endpoint to list leaders for autocomplete.
At least 2 characters are required to make a name search.
- Parameters
q (string) – Search string.
l (int) – Maximum number of returned items.
- Returns
A tuple:
JSON containing information describe in AutocompleteUserSchema
HTTP return code : 200
additional header (content as JSON)
- Return type
(string, int, dict)
- collectives.api.autocomplete_user.autocomplete_users()#
API endpoint to list users for autocomplete.
At least 2 characters are required to make a name search.
- Parameters
q (string) – Search string.
l (int) – Maximum number of returned items.
- Returns
A tuple:
JSON containing information describe in AutocompleteUserSchema
HTTP return code : 200
additional header (content as JSON)
- Return type
(string, int, dict)
- collectives.api.autocomplete_user.autocomplete_users_create_rental()#
API endpoint to list users for autocomplete.
At least 2 characters are required to make a name search.
- Parameters
q (string) – Search string.
l (int) – Maximum number of returned items.
- Returns
A tuple:
JSON containing information describe in AutocompleteUserSchema
HTTP return code : 200
additional header (content as JSON)
- Return type
(string, int, dict)
Module collectives.api.event
#
API to get the event list in index page.
- class collectives.api.event.AutocompleteEventSchema(*args, **kwargs)#
Schema under which autocomplete suggestions are returned
- class Meta#
Fields to expose
- opts: LoadInstanceMixin.Opts = <flask_marshmallow.sqla.SQLAlchemyAutoSchemaOpts object>#
- class collectives.api.event.QuestionAnswerSchema(*args, **kwargs)#
Schema according to which question answers are returned
- delete_uri#
URI for deleting the answer.
- Type
marshmallow.fields.Function
- opts: LoadInstanceMixin.Opts = <flask_marshmallow.sqla.SQLAlchemyAutoSchemaOpts object>#
- class collectives.api.event.QuestionSchema(*args, **kwargs)#
Schema according to which question are returned
- class Meta#
Fields to expose
- model#
alias of
collectives.models.question.Question
- opts: LoadInstanceMixin.Opts = <flask_marshmallow.sqla.SQLAlchemyAutoSchemaOpts object>#
- collectives.api.event.autocomplete_event()#
API endpoint for event autocompletion.
At least 2 characters are required to make a name search.
- Parameters
q (string) – Search string. Either the event id or a substring from the title
l (int) – Maximum number of returned items.
aid (list[int]) – List of activity ids to include. Empty means include events for any activity
eid (list[int]) – List of event ids to exclude
- Returns
A tuple:
JSON containing information describe in AutocompleteUserSchema
HTTP return code : 200
additional header (content as JSON)
- Return type
(string, int, dict)
- collectives.api.event.event_question_answers(event_id: int)#
API endpoint for listing answers to an event’s questions
- Parameters
event_id – Id of the event
- collectives.api.event.events()#
API endpoint to list events.
It can be filtered using tabulator filter and sorter. It is paginated using
page
andsize
GET parameters. Regular users cannot see Pending event.- Returns
A tuple:
JSON containing information describe in EventSchema
HTTP return code : 200
additional header (content as JSON)
- Return type
(string, int, dict)
Update a SQLAlchemy query object with a filter that removes Event with a status that the current use is not allowed to see
Moderators can see all events
Normal users cannot see ‘Pending’ events
Activity supervisors can see ‘Pending’ events for the activities that they supervise
Leaders can see the events that they lead
Users with role for an activity can see ‘Activity’ events
Users with any role can see ‘Activity’ events without activities
- Parameters
query (
sqlalchemy.orm.query.Query
) – The original query- Returns
The filtered query
- Return type
sqlalchemy.orm.query.Query
Module collectives.api.userevent
#
API used to get events linked to a user for profiles.
Event schema is the one from collectives.api.event.EventSchema
- class collectives.api.userevent.RegistrationEventSchema(*args, **kwargs)#
Schema to describe a en event with a specific registration
- class Meta#
Fields to expose
- opts: LoadInstanceMixin.Opts = <flask_marshmallow.sqla.SQLAlchemyAutoSchemaOpts object>#
- class collectives.api.userevent.RegistrationSchema(*args, **kwargs)#
Schema to describe a registration
- opts: LoadInstanceMixin.Opts = <flask_marshmallow.sqla.SQLAlchemyAutoSchemaOpts object>#
- collectives.api.userevent.leader_events(leader_id)#
Get all event of a leader.
- Parameters
user_id (int) – ID of the user.
- Returns
A tuple:
JSON containing information describe in EventSchema
HTTP return code : 200
additional header (content as JSON)
- Return type
(string, int, dict)
- collectives.api.userevent.user_events(user_id)#
Get all event of a user.
Users without roles can only see their own events.
- Parameters
user_id (int) – ID of the user.
- Returns
A tuple:
JSON containing information describe in EventSchema
HTTP return code : 200
additional header (content as JSON)
- Return type
(string, int, dict)