from udata.core.dataset.api_fields import dataset_fields from udata.core.followers.api import FollowAPI from udata.core.reuse.api_fields import reuse_fields from udata.features.transfer.models import Transfer from .api_fields import (me_fields, user_fields, user_page_fields, user_suggestion_fields, notifications_fields, avatar_fields) from .forms import UserProfileForm from .search import UserSearch ns = api.namespace('users', 'User related operations') me = api.namespace('me', 'Connected user related operations') search_parser = api.search_parser(UserSearch) @me.route('/', endpoint='me') class MeAPI(API): @api.secure @api.doc('get_me') @api.marshal_with(me_fields) def get(self): '''Fetch the current user (me) identity''' return current_user._get_current_object() @api.secure @api.marshal_with(user_fields) @api.doc('update_me', responses={400: 'Validation error'}) def put(self, **kwargs):
) from .api_fields import ( apikey_fields, me_fields, me_metrics_fields, user_fields, user_page_fields, user_suggestion_fields, ) from .forms import UserProfileForm from .search import UserSearch ns = api.namespace('users', 'User related operations') me = api.namespace('me', 'Connected user related operations') search_parser = api.search_parser(UserSearch) filter_parser = api.parser() filter_parser.add_argument( 'q', type=str, help='The string to filter items', location='args', required=False) @me.route('/', endpoint='me') class MeAPI(API): @api.secure @api.doc('get_me') @api.marshal_with(me_fields) def get(self): '''Fetch the current user (me) identity''' return current_user._get_current_object()
from .api_fields import ( dataset_fields, dataset_page_fields, dataset_suggestion_fields, license_fields, resource_fields, resources_order, upload_fields, ) from .models import Dataset, Resource, DatasetIssue, FollowDataset, Checksum, License from .permissions import DatasetEditPermission from .forms import DatasetForm, ResourceForm, DatasetFullForm from .search import DatasetSearch ns = api.namespace('datasets', 'Dataset related operations') search_parser = api.search_parser(DatasetSearch) common_doc = { 'params': {'dataset': 'The dataset ID or slug'} } @ns.route('/', endpoint='datasets') @api.doc(get={'id': 'list_datasets', 'model': dataset_page_fields, 'parser': search_parser}) @api.doc(post={'id': 'create_dataset', 'model': dataset_fields, 'body': dataset_fields}) class DatasetListAPI(ModelListAPI): model = Dataset form = DatasetFullForm fields = dataset_fields search_adapter = DatasetSearch
from udata.core.followers.api import FollowAPI from udata.core.storages.api import (uploaded_image_fields, image_parser, parse_uploaded_image) from .api_fields import (reuse_fields, reuse_page_fields, reuse_suggestion_fields, reuse_type_fields, dataset_ref_fields) from .forms import ReuseForm from .models import FollowReuse from .permissions import ReuseEditPermission from .search import ReuseSearch ns = api.namespace('reuses', 'Reuse related operations') common_doc = {'params': {'reuse': 'The reuse ID or slug'}} search_parser = api.search_parser(ReuseSearch) @ns.route('/', endpoint='reuses') class ReuseListAPI(API): @api.doc('list_reuses', parser=search_parser) @api.marshal_with(reuse_page_fields) def get(self): return search.query(ReuseSearch, **multi_to_dict(request.args)) @api.secure @api.doc('create_reuse', responses={400: 'Validation error'}) @api.expect(reuse_fields) @api.marshal_with(reuse_fields) def post(self): '''Create a new object'''
) from .api_fields import ( reuse_fields, reuse_page_fields, reuse_suggestion_fields, reuse_type_fields, dataset_ref_fields ) from .forms import ReuseForm from .models import FollowReuse from .permissions import ReuseEditPermission from .search import ReuseSearch ns = api.namespace('reuses', 'Reuse related operations') common_doc = { 'params': {'reuse': 'The reuse ID or slug'} } search_parser = api.search_parser(ReuseSearch) @ns.route('/', endpoint='reuses') class ReuseListAPI(API): @api.doc('list_reuses', parser=search_parser) @api.marshal_with(reuse_page_fields) def get(self): return search.query(ReuseSearch, **multi_to_dict(request.args)) @api.secure @api.doc('create_reuse', responses={400: 'Validation error'}) @api.expect(reuse_fields) @api.marshal_with(reuse_fields) def post(self): '''Create a new object'''
member_fields, refuse_membership_fields, ) from udata.core.dataset.api_fields import dataset_full_fields from udata.core.dataset.models import Dataset from udata.core.discussions.api import discussion_fields from udata.core.discussions.models import Discussion from udata.core.issues.api import issue_fields from udata.core.issues.models import Issue from udata.core.reuse.api_fields import reuse_fields from udata.core.reuse.models import Reuse from udata.core.storages.api import uploaded_image_fields, image_parser, parse_uploaded_image ns = api.namespace("organizations", "Organization related operations") search_parser = api.search_parser(OrganizationSearch) common_doc = {"params": {"org": "The organization ID or slug"}} @ns.route("/", endpoint="organizations") class OrganizationListAPI(API): """Organizations collection endpoint""" @api.doc("list_organizations", parser=search_parser) @api.marshal_with(org_page_fields) def get(self): """List or search all organizations""" return search.query(OrganizationSearch, **multi_to_dict(request.args)) @api.secure
request_fields, member_fields, logo_fields, ) from udata.core.dataset.api_fields import dataset_fields from udata.core.dataset.models import Dataset from udata.core.discussions.api import discussion_fields from udata.core.discussions.models import Discussion from udata.core.issues.api import issue_fields from udata.core.issues.models import Issue from udata.core.reuse.api_fields import reuse_fields from udata.core.reuse.models import Reuse ns = api.namespace('organizations', 'Organization related operations') search_parser = api.search_parser(OrganizationSearch) common_doc = { 'params': {'org': 'The organization ID or slug'} } @ns.route('/', endpoint='organizations') class OrganizationListAPI(API): '''Organizations collection endpoint''' @api.doc('list_organizations', parser=search_parser) @api.marshal_with(org_page_fields) def get(self): '''List or search all organizations''' return search.query(OrganizationSearch, **multi_to_dict(request.args))