-
Notifications
You must be signed in to change notification settings - Fork 6
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
Added org and tag routes #115
base: staging
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,11 +164,10 @@ def submit_article_for_review(org_slug, slug): | |
|
||
return article | ||
|
||
|
||
@blueprint.route('/api/organizations/<org_slug>/articles/<slug>', | ||
methods=('DELETE',)) | ||
@jwt_required | ||
def reviewed_article(slug, org_slug, **kwargs): | ||
def remove_article(slug, org_slug, **kwargs): | ||
profile = current_user.profile | ||
organization = Organization.query.filter_by(slug=org_slug).first() | ||
article = Article.query.filter_by(slug=slug).first() | ||
|
@@ -181,7 +180,27 @@ def reviewed_article(slug, org_slug, **kwargs): | |
|
||
organization.pending_articles.remove(article) | ||
organization.save() | ||
article.add_organization(organization) | ||
article.remove_organization(organization) | ||
article.save() | ||
|
||
return '', 200 | ||
|
||
|
||
@blueprint.route('/api/organizations/<org_slug>/articles/<slug>', | ||
methods=('PUT',)) | ||
@jwt_required | ||
@marshal_with(article_schema) | ||
def add_article(slug, org_slug, **kwargs): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For add article, return the article that was added |
||
profile = current_user.profile | ||
organization = Organization.query.filter_by(slug=org_slug).first() | ||
article = Article.query.filter_by(slug=slug).first() | ||
if not organization.moderator(profile): | ||
raise InvalidUsage.not_admin() | ||
if article not in organization.pending_articles: | ||
raise InvalidUsage.article_not_found() | ||
organization.pending_articles.remove(article) | ||
organization.save() | ||
article.add_organization(organization) | ||
article.save() | ||
|
||
return article |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,7 +134,7 @@ def invite_moderator(slug, username): | |
@blueprint.route('/api/tags/<slug>/articles/<articleSlug>', methods=('PUT',)) | ||
@jwt_required | ||
@marshal_with(article_schema) | ||
def review_article(slug, articleSlug): | ||
def add_article(slug, articleSlug): | ||
profile = current_user.profile | ||
tag = Tags.query.filter_by(slug=slug).first() | ||
if not tag: | ||
|
@@ -147,12 +147,36 @@ def review_article(slug, articleSlug): | |
raise InvalidUsage.article_not_found() | ||
if article.needsReview: | ||
article.remove_needReviewTag(tag) | ||
article.add_tag(tag) | ||
if article.is_allTagReviewed(): | ||
article.set_needsReview(False) | ||
article.save() | ||
return article | ||
|
||
|
||
@blueprint.route('/api/tags/<slug>/articles/<articleSlug>', methods=('DELETE',)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2 Lines of space between each route/function |
||
@jwt_required | ||
@marshal_with(article_schema) | ||
def remove_article(slug, articleSlug): | ||
profile = current_user.profile | ||
tag = Tags.query.filter_by(slug=slug).first() | ||
if not tag: | ||
raise InvalidUsage.tag_not_found() | ||
if tag not in profile.moderated_tags: | ||
raise InvalidUsage.not_moderator() | ||
|
||
article = Article.query.filter_by(slug=articleSlug).first() | ||
if not article: | ||
raise InvalidUsage.article_not_found() | ||
if article.needsReview: | ||
article.remove_needReviewTag(tag) | ||
article.remove_tag(tag) | ||
if article.is_allTagReviewed(): | ||
article.set_needsReview(False) | ||
article.save() | ||
return article | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2 Lines of space between each route/function |
||
|
||
#Route to return an article filtered by tag names | ||
@blueprint.route('/api/user/tags/articles', methods=('GET',)) | ||
@jwt_optional | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 lines of space between each function