Commit graph

80 commits

Author SHA1 Message Date
Alex
347a4bbc75
[deploy] Add contexts and permissions to liquid tags (#8917)
* Make liquid tags adhere to context and permission

* Undo updates to all liquid tags and update error

* ACTUALLY update errors this time

* Typo

* Refactor error handling and add support for Comment

* Fix specs

* Code cleanup

* Prettify error message

* Add comment clarifying error

* parsed --> parse

* Use a policy for validating roles

* Fix pretty error message

* Return early if valid source

* Get rid of duplicate current_user

* Add comment to Pundit.authorize

* LiquidTagPolicy specs

* Update liquid tag docs

* Update docs

* Use parse_context argument for clarity

* Remove duplicate guard clause for VALID_ROLES

* Update docs
2020-06-30 14:53:18 -04:00
Alex
db4e37781f
[deploy] User subscriptions liquid tag MVP (#8871)
* UX (view, style, JS) progress

* base_data updates

* More JS updates

* Remove unnecessary param of author_id

* Remove author_id from controller

* Restrict email to admins

* Introduce profile images

* Remove base_data and update tag for source

* Use .key?

* I gotchu Codeclimate, don't worry :)

* Add click event listeners to modal buttons

* Refactor

* More refactor

* Refactor subscriber

* Use userData() for subscriber

* Reorganize

* Code cleanup

* Add subscription API call and favor textContent

* Fix API call and showSubscribed

* Add Apple Auth logic and change links to buttons

* Update success message

* Add Apple email check and spec

* Fix default sign in state

* Remove email from async_info :(

* Refactor markdown classes

* Single quote consistency

* Modal bug attempt & subscriber image on success

* Refactor passing source to tags and fix preview
2020-06-25 13:13:19 -04:00
Molly Struve
07f8964007
[deploy] Tweak How We Track Ambiguous Routes to Make them Easier to Track (#8112) 2020-05-28 10:34:39 -05:00
Molly Struve
0edca1fe2c
[deploy] Track How Often We Hit Ambiguous Routes (#8098) 2020-05-28 07:56:00 -05:00
rhymes
0976132425
[deploy] RSS feed: add article tags as categories (#8046) 2020-05-26 15:51:33 -04:00
Molly Struve
61cda701c5
Track Article IDs for Controller Requests (#8038) 2020-05-25 11:59:34 -04:00
Renan Bona
b93306ecc8
Create Articles builder and refactor articles_controller (#7381)
* Create Articles entity and refactor articles_controller

* Add safe operator into action new from articles_controller

* Renaming files for better understanding

* Move some logic from the articles controller to articles builder

* Add method normalized text into articles builder
2020-04-28 12:24:51 +02:00
Alex
441cd4f7db
[deploy] Update manual Fastly header assignments (#7119) 2020-04-07 13:22:32 -04:00
Ben Halpern
883264c8ab
Do not render or link to empty rss feeds (#6429) [deploy]
* Do not render or link to empty rss feeds

* Fix tests up
2020-03-03 21:37:51 -05:00
rhymes
bc385ae6d5
Switch decorators to Rails builtin decorations - take 2 (#6125) [deploy]
* Revert "Revert "[deploy] Switch decorators from Draper to Rails builtin decorations (#6040)" (#6122) [deploy]"

This reverts commit d438349550.

* Enable serialization for decorators

* Refactor and test default home feed serialization

* Improve spec

* Applied @vaidehijoshi suggestions

* Applied @citizen428 suggestions

* Make CodeClimate happy

* Cleanup stories_index_spec.rb

* Refactor UserDecorator#cached_followed_tags to loop less
2020-02-19 15:30:53 -05:00
rhymes
d438349550
Revert "[deploy] Switch decorators from Draper to Rails builtin decorations (#6040)" (#6122) [deploy]
This reverts commit cc53b55a4a.
2020-02-17 11:28:32 -05:00
rhymes
cc53b55a4a
[deploy] Switch decorators from Draper to Rails builtin decorations (#6040)
* Convert SponsorshipDecorator to Rails decorator

* Remove empty ReactionDecorator

* Rename SponsorshipDecorator#level_color_hex to level_background_color

* Convert CommentDecorator to Rails decorator

* Add specs and fix bugs for NotificationDecorator

* Convert NotificationDecorator to Rails decorator

* Add specs and fix bugs for OrganizationDecorator

* Convert OrganizationDecorator to Rails decorator

* Add specs to PodcastEpisodeDecorator and fix bugs

* Convert PodcastEpisodeDecorator to a Rails decorator

* Add missing specs for ArticleDecorator and fix bugs

* Convert ArticleDecorator to Rails decorator

* Add missing specs to UserDecorator and fix issues

* Convert UserDecorator to Rails decorator

* Add .decorate_collection method

* Add decorator for AR relations and remove Draper

* Rename BaseDecorator back to ApplicationDecorator

* Rename .decorate_ back to .decorate

* Restore decorate_collection (WTH)

* Add decorated?

* Fix bugs and failing specs

* Decoration should always be explicit
2020-02-17 09:32:32 -05:00
rhymes
c41d66e900
Replace ban/banned with suspend/suspended in user facing text (#5816) [deploy] 2020-02-10 10:12:53 -05:00
Keith Bennett
3c980e7b83 Fix long line lints (#5062) 2019-12-26 13:24:24 -05:00
Molly Struve
aa9361798d
Return not_found response rather than trying to authorize a nil object (#5093) [deploy] 2019-12-13 09:39:40 -06:00
Molly Struve
6ba2853168 Ensure that we have a slug and owner before attempting to lookup an article (#5079) 2019-12-11 13:19:45 -05:00
Brad Pauly
b59aba415d ArticlesController#feed refactor (#4498)
* Move query details into model.
Reorganize filtering initial results by params.

* Fixups from feedback.
2019-10-30 12:35:53 -04:00
Araslanov Evgeny
60d8a07276 Fix invalid body_markdown in article with video (#4258) [ci skip] 2019-10-08 15:41:44 -04:00
Andy Zhao
3b0f6f2834 Refactor remove_all and remove_each notifications and fix orphaned notifications (#3570) 2019-09-25 15:31:56 -04:00
Anna Buianova
4c9a40be41 Dispatch events to the webhook endpoints #3715 (#3872)
* Start with webhooks: table and model

* Start with webhooks api

* Start with webhooks api

* Webhook::Event class and events list

* Remove commented callbacks

* Start with sending events to webhook endpoints

* A couple of tests for Articles::Creator

* Send event to webhook endpoint on article destroy

* Dispatch event on article update

* Dispatch event when an article updated from admin

* Spec for the webhook job

* One more test for the dispatch event job

* Integration-like spec for event dispatching to webhook endpoints when creating an article

* Use Addressable::URI to parse endpoint url

* Add oj as a faster fast_jsonapi backend

* Renamed serializers

* Move article serialization out of a model

* Don't allow to create a webhook event with invalid type

* Add fields for ArticleSerializer

* Fix webhook event job specs

* Specify timeout when dispatching events

* Fix webhook job spec

* Change webhook events queue name

* Change serialized article fields for the dispatchable events

* Include user data when serializing an article for webhook event

* Moved decorating out of Webhook::DispatchEvent, fixed most specs

* Fix route in ArticleSerializer

* Move Article decoration to Webhook::PayloadAdapter

* Refactor image url helpers to avoid including helpers into serializer

* Fix specs

* Default url options for production
2019-09-07 13:17:45 -04:00
Feruz Oripov
0ccc62ffa3 Refactoring possible unprotected redirect. (#3825)
* Refactoring possible unprotected redirect.

* Security refactoring tag_adjustments_controller.rb.

* Security refactoring tag_adjustments_controller.rb.

* Security refactoring articles_controller.rb.

* Security refactoring internal/welcome_controller.rb

* Security refactoring tags_controller.rb.

* Security refactoring comments_controller.rb.

* Security refactoring stories_controller.rb.
2019-08-27 10:13:38 -04:00
Anna Buianova
9b04654e3b Refactor articles creation (#3797)
* Refactor articles creation

* Create article from /admin via a service for consistency

* Move articles destroy logic into Articles::Destroyer
2019-08-23 14:43:29 -04:00
Ben Halpern
04a810d739
Fix video image redirect issue (#3778) 2019-08-20 13:18:38 -04:00
rhymes
4689cdd266 Collection: remove optional user and add tests (#3383) 2019-08-02 10:15:04 -04:00
Mac Siri
e28aaecca4
Make xhr request's method dynamic for archiving. (#3335) 2019-07-15 14:40:01 -04:00
Andy Zhao
da224d56aa Remove notifications if article is unpublished (#3362)
* Add tests for article notifications

* Remove notifications if unpublished and refactor
2019-07-03 16:50:23 -04:00
rhymes
55634ad68f Display stats for organization article (#3232)
There was a bug where the frontend was not passing the organization id to the backend, and thus the fetching of the stats failed for organization articles.

This also adds a bit of error handling for `fetch` API
2019-06-19 09:17:35 -04:00
rhymes
7f2045b250 Pro Analytics: stats for a single article (#3120)
* Add /stats endpoint for articles, opened only to Pro users

* Add analytics to article stats page

* Add stats button to the article page and test stats page
2019-06-13 19:02:09 -04:00
Ben Halpern
a3a9f51103
Fix improper archive redirect (#3064) 2019-06-06 17:03:59 -04:00
Andy Zhao
47d9ec27fb Allow users to belong to multiple orgs (#2583)
* Allow user to have many orgs

* Allow users to handle multi orgs in settings

* Make rounded buttons inline

* Add multi org function to dashboards

* Fix merge conflicts

* Fix mistake in merge conflict fix oops

* Display the correct membership level

* Fix accessibility issues

* Display organizations for article editors

* Handle submitting org id with preact editors

* Make listings work with multiple organizations

* Allow listings to have multiple orgs on create

* Display the correct number of credits for each org

* Move script tag to Webpack

* Allow multi orgs for purchasing and viewing credits

* Use OrganizationMembership as authorization check

* Display multiple organizations for notifications

* Allow dashboard to be viewable under multi-orgs

* Remove unused method

* Add multi-org functionality for article editors

* Show pro dashboard buttons for member+ org levels

* Leave the correct organization

* Allow article API to change org id

* Add left-out authorization method oops

* Make nav buttons a bit more clear

* Fix merge conflict

* Fix adding org id for /api/articles and tests

* Fix tests for org policy

* Use proper logic for displaying org members

* Update org actions with new authorization

* Use correct org when creating a listing

* Remove additional payment charge oops

* Mark org notifications as read with authorization

* Remove deprecated post_as_organization attribute

* Use new org_admin syntax

* Remove deprecated org logic for article create and update

* Default all RSS posts to not belong to any org

* Render org_member page for guest users

* Update org policy spec to work with multi orgs

* Use org_membership for org traits and move identity code

* Use org_member trait

* Update to work with multi-orgs

* Validate article's org_id if param org_id is blank

* Make  a let variable

* Remove unnecessary eager load for credits

* Fix HTML structure and org logic for non-org users

* Update credits spec for multi-org

* Add test for failed payment when purchased by org

* Lint listings_spec

* Test that the listing was created under the user

* Add tests for POST /listings multi-org

* Use double quotes for classes

* Fix /manage and a few other multi-org bugs

* Fix test for multi org

* Use correct method SQL exists? not Rails exist?

* Fix reads spec for multi-org

* Fix org_controller actions to work with multi org

* Test only multi org and not old usage and fix leave_org

* Fix org showing user profile img test for multi-org

* Fix org logic for users with no orgs

* Remove switch org functionality

* Update tests and add hidden param for org id

* Redirect to the specific organization

* Test other org button actions

* Use settings_notice instead of legacy notice and refactor

* Fix weird extra end issue prob from merge conflicts

* Test for with new flash key

* Fix user_views_org tests for multi-org

* Test for new flash message

* Update snapshot with new a11y html

* Move styling to stylesheet

* Add site admins functionality

* Move org_member? method in user model and refactor

* Use unspent_credits_count for organizations

* Add tests for /listings/new and minor bug fixes

* Use .present? in case of empty array

* Fix a lingering deprecated method

* Use greater than 1 for random numbers

* Add tests for counting spent and unspent credits
2019-06-04 09:30:52 -04:00
Jess Lee
c3e2a0c5f1 Add missing instance var for /manage & Bust rails cache on comments (#3004) 2019-05-30 12:23:20 -04:00
rhymes
38aa45c8e3 Cleanup bodyPreview component (#2980) [ci skip] 2019-05-28 23:55:37 -04:00
rhymes
6a626e819d Refactor: fix issues raised by bullet (#2965)
* Preload organization, not user

* Preload users only when needed

* Pre-load podcasts for podcast episodes in API

* Avoid eager loading error by loading rating votes separately

* Preload associations for moderation

* Preload user comments in trees

* Preload organization for non org dashboard and cleanup queries

* Optimize ArticleSuggester to only load N articles at need

* Remove eager loading and pass variables to partials for easier debug

* Reorganize tags validation code and ignore actsastaggableon eager loading issues

* Remove unused eager loading and bring up comments relation

* Preload podcasts when loading podcast episodes

* Fix views specs

* Make sure ArticleSuggester never returns duplicates

* Remove commented code

* Re-trigger build

* Move suggested articles back to view to respect fragment caching
2019-05-28 17:32:53 -04:00
Ben Halpern
07597d307c
Fix bug to allow users to remove org from article (#2930) 2019-05-21 17:16:16 -04:00
rhymes
09a99d93a3 Return errors instead of raising an exception on ArticleCreation (#2922) 2019-05-21 15:18:02 -04:00
rhymes
85e33583c8 Fix organization article ownership code (#2904)
* Fix organization article ownership code

* Query the DB in case of user change only if needed
2019-05-20 18:50:04 -04:00
Ben Halpern
6c2498b1b8
Render correct editor based on article's existing format (#2856)
* Render correct editor based on article's existing format

* Add check for user in /new
2019-05-16 15:25:43 -04:00
Ben Halpern
fb6904f86d
Fix up articles controller (#2855)
* Fix up articles controller

* Update request specs

* Add proper post_under_org tests

* Remove create_job_opportunity

* Add user profile back in
2019-05-16 13:56:26 -04:00
rhymes
941ab4178b Articles API: create and update (#2844)
* Add system test to create article from the editor

* Move article creation from API to app controller

* Fix system test to edit posts

* Move article update from API to app controller

* Rewrite create article API using API key

* Add main_image and canonical_url to allowed creation params

* Rewrite update article API using API key

* Fix tests and have Comments API inherit from API
2019-05-16 12:26:24 -04:00
rhymes
66ddcbca02 Upgrade rubocop and rubocop-performance (#2802) [ci skip] 2019-05-13 19:21:24 -04:00
Dana Scheider
b2a8f69f83 Allow archiving of posts (#2798)
* This commit adds the "archived" attribute to the Article model, which will
enable users to automatically filter archived articles/drafts from appearing
on their dashboard. It also adds an ellipsis menu with a link to archive the
article. I've also moved the Mute Notifications button into the ellipsis menu
as well.

* Add ellipsis menu and make it work

* Fix logic error

* Hide ellipsis menus when you click elsewhere on the body

* Extract function to remove duplication

* Ensure that menu is hidden when the ellipsis button is clicked on an open menu

* Ensure that archiving post button works and that 'archived' param is accepted by the controller

* Enable link to toggle showing/hiding archived articles

* Make 'mute' and 'archive' buttons in ellipsis dropdown list work

* Refactor to make Code Climate happy

* Minor JS refactors
2019-05-13 15:40:52 -04:00
Ben Halpern
c7d7d55460
[WIP] Move both v1 and v2 editor to v2 preact-driven editor (#2797)
* Initial work on v2

* Initial changes merger

* Work to finalize v1/v2 editor adjustments

* Clean up styling

* Fiddle with form margins

* Fix some tests

* Change video

* skip a couple tests

* Modify tests to work with new code
2019-05-13 12:27:36 -04:00
Wes Delp
f08f5fcdbf Customize RSS feed by tag (#2634)
* add tag param and filter

* add tag filter request specs

* order user above tag to maintain existingdefault

* refactor #new for code climate

* add rss feed spec

* move feed tags under explicit route
2019-05-03 11:35:54 -04:00
Ben Halpern
5eb8036bad
Fix buffer_updates conditional in /manage (#2636) 2019-05-01 10:17:35 -04:00
Ben Halpern
158f56bc9d
Add page for users to "manage" their posts after publication (distribution, etc.) (#2627)
* Set up basic /manage route

* Add basic article manage page

* Add tips and finalize permissions for /manage

* Add final test and add manage button to article show

* Update failing specs
2019-05-01 09:00:09 -04:00
Ben Halpern
9578a15579
Remove unnecessary map functions in stories controller (#2402) 2019-04-12 01:10:08 -04:00
rhymes
5782ffd7e0 Use published scope for articles (#2374)
* Use published scope for articles

* Fix variable name

* The sequencing in the union query matters

* Fix spec

* Restore a published: true condition

* This test is actually misleading due to the union

* Revert this change, not sure why it's not a relation

* Fix useless diff
2019-04-11 13:18:26 -04:00
Abraham Williams
9cb40e546b Enables Rails cops (#2186)
* Enable Rails cops

* Fix Rails/DynamicFindBy

* Fix Rails/HttpStatus

* Fix Rails/Blank

* Fix Rails/RequestReferer

* Fix Rails/ActiveRecordAliases

* Fix Rails/FindBy

* Fix Rails/Presence

* Fix Rails/Delegate

* Fix Rails/Validation

* Fix Rails/PluralizationGrammar

* Fix Rails/Present

* Fix Rails/Output

* Fix Rails/Blank

* Fix Rails/FilePath

* Fix Rails/InverseOf

* Fix Rails/LexicallyScopedActionFilter

* Add Rails/OutputSafety to TODO

* Add Rails/HasManyOrHasOneDependent to TODO

* Add Rails/SkipsModelValidations to TODO
2019-03-25 09:25:55 -04:00
Tim Lange
3494264404 Enabled rubocop/lint (#2130)
* WIP: Enabled rubocop/lint

* FIX: Fixed failing test

* FIX: Small change to return

* FIX: Changed indent
2019-03-21 10:53:44 -04:00
Ben Halpern
90a44b1687
Add prefill text for /new (#2108) 2019-03-18 19:08:00 -04:00