-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: event import #5514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
iamareebjamal
merged 8 commits into
fossasia:development
from
YogeshSharma0201:fix_event_import
May 14, 2019
Merged
fix: event import #5514
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3c016b7
fix event import
YogeshSharma0201 82e14cc
merge development and fix conflicts
YogeshSharma0201 fcdb920
hound_fix
YogeshSharma0201 39ebcac
Merge branch 'development' of github.com:fossasia/open-event-server i…
YogeshSharma0201 a68ce32
Merge developement and resolve conflicts
YogeshSharma0201 d241980
Update import_helpers.py
iamareebjamal e571707
Update import_helpers.py
iamareebjamal 311e585
Update import_helpers.py
iamareebjamal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| from flask_rest_jsonapi import ResourceDetail, ResourceList | ||
YogeshSharma0201 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| from flask_jwt import current_identity as current_user | ||
YogeshSharma0201 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| from app.api.schema.import_jobs import ImportJobSchema | ||
| from app.models import db | ||
| from app.api.helpers.db import safe_query | ||
YogeshSharma0201 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| from app.models.import_job import ImportJob | ||
| from app.models.user import User | ||
| from app.api.helpers.permissions import jwt_required | ||
| from app.api.helpers.permission_manager import has_access | ||
YogeshSharma0201 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| class ImportJobList(ResourceList): | ||
YogeshSharma0201 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """ | ||
| List ImportJob | ||
| """ | ||
| def query(self, view_kwargs): | ||
| query_ = self.session.query(ImportJob) | ||
| user_id = current_user.id | ||
| user = safe_query(self, User, 'id', user_id, 'user_id') | ||
| if not has_access('is_user_itself', user_id=user.id): | ||
| raise ForbiddenException({'source': ''}, 'Access Forbidden') | ||
YogeshSharma0201 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| query_ = query_.join(User, User.id == ImportJob.user_id).filter(User.id == user.id) | ||
| return query_ | ||
|
|
||
| decorators = (jwt_required,) | ||
| schema = ImportJobSchema | ||
| data_layer = {'session': db.session, | ||
| 'model': ImportJob, | ||
| 'methods': { | ||
| 'query': query | ||
| }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| from marshmallow.validate import Range | ||
YogeshSharma0201 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| from marshmallow_jsonapi import fields | ||
| from marshmallow_jsonapi.flask import Relationship | ||
YogeshSharma0201 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| from app.api.helpers.utilities import dasherize | ||
| from marshmallow_jsonapi.flask import Schema | ||
| from utils.common import use_defaults | ||
|
|
||
|
|
||
| @use_defaults() | ||
| class ImportJobSchema(Schema): | ||
| """ | ||
| Api schema for ImportJob Model | ||
| """ | ||
|
|
||
| class Meta: | ||
| """ | ||
| Meta class for ImportJob Api Schema | ||
| """ | ||
| type_ = 'import-job' | ||
| self_view = 'v1.image_job_detail' | ||
YogeshSharma0201 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| self_view_kwargs = {'id': '<id>'} | ||
| inflect = dasherize | ||
|
|
||
| id = fields.Str(dump_only=True) | ||
| task = fields.Str(allow_none=False) | ||
| starts_at = fields.DateTime(required=True, timezone=True) | ||
| result = fields.Str(allow_none=True) | ||
| result_status = fields.Str(allow_none=True) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.