Commit graph

27 commits

Author SHA1 Message Date
Philip How
3ceb9a178a
Allow some badges to be awarded multiple times (#20876)
* Add migration, update badgeachievements model and admin view to set flag on badges

* Show multiple badges on profile

* update factory

* badge model validation

* safe navigation to badge?

* add null: false to migratrion
2024-04-23 16:33:43 -04:00
Jeremy Friesen
aa7712a80e
Extracting container for allowed tags & attrs (#15338)
* Extracting container for allowed tags & attrs

Prior to this commit, we had several different locations in which we
specified ALLOWED_TAGS and ALLOWED_ATTRIBUTES for HTML rendering and
sanitization.

Curious to see how these either intersected or didn't, I opted to
create a container module that allows for us to more readily normalize
these allowed tags and attributes.  It's possible that we won't do any
normalization, but this work helps make that easier.

Ideally, I'd love us to contextualize "why did we choose the
tags/attributes we chose?"  But for now, I think consolidating these
tags and attributes will help make adding a `details` and `summary` tag
easier.

This relates to forem/rfcs#296

See [Google Sheet][1] for analysis of what tags/attributes are used, the
intersection and union.

[1]:https://docs.google.com/spreadsheets/d/1yj-a1qus1o0o4cj-_gOMP5yteeg-_f3s5z7kvK0Y7RM/edit#gid=0

* Fixing misnamed constant

* Fixing misnamed constant

* Extracting additional HtmlRendering use cases

* Adding comparative documentation for HTML tags

* Fixing broken parameter signature

* Moving constants into MarkdownProcessor
2021-12-16 12:24:45 -05:00
Jeremy Friesen
ee0a521a83
Favoring delete_all on user relationships (#15443)
* Favoring delete_all on user relationships

Prior to this commit, several of the user's "has_many" were marked as
`depenedent: :destroy`.

In the case of :destroy, ActiveRecord instantiates each object and then
runs destroy. Whereas in the case of :delete, ActiveRecord issues a SQL
command to delete the related files.

It is often "safer" to use :destroy, as it guarantees that you'll
instantiate the record and run it's callbacks. But sometimes you have
to go with the speed of SQL.

And while not directly related to #15424 it is representative of our
callback ecosystem creating some unexpected computational loads.

Related to #15442 and #15424

* Noting models that user no longer cascade destroys
2021-11-23 11:50:12 -05:00
Molly Struve
e87dead7ad
Use new UserSetting and UserNotificationSettings and Ignore Related User Table Fields (#14121)
* schema file undelete description

* feat: v1 of the script

* Flesh out remaining enums under their categories

* complete UsersSettings data update script

* complete DUS for relevant attributes in users and profiles tables

* complete DUS for users_notification_settings

* alphabetize user_settings sql file

* safeguard against null values for "null: false" settings

* Set up actual UsersSettings DUS and specs files

* fix broken DUS script

* complete specs for UsersSetting DUS

* Address QA of specs

* complete specs for users_notification_settings DUS

* fix the typos (thanks Julianna!)

* begin implementation

* still building

* add missing attribute "email_membership_newsletter"

* complete sync code (except race condition for user profile)

* complete implementation, remains tests

* Address PR review and fix Travis fails

* remove superfluous Profile.new

* fix travis fails

* feat: update the users_notification_setting attributes from the user model

* feat: use the config fonts enums to display the fonts

* feat: loop through the keys

* fix profile = nil blowing up; add specs for notification_setting model

* remove unneeded spec

* remove feed validation until after sync code removed; fixes feed_import spec failures

* remove spec associated with feed_url validation in user_setting model

* fix failing spec 😅

* add TODO

* feat: set the user settings in the user controller  and use it in the customization form

* feat: move some update logic to the users settings controller thats being used from customization

* feat: show the updated values form the users_settingd and not the user instance

* Generalize redirect back to current tab

* still trying to reflect changed theme upon refresh

* customizations take effect on refresh

* remove 'with_feed' scope from user model

Co-authored-by: Jamie Gaskins <jamie@forem.com>

* start with takeover for fields previously in profiles table

* Takeover code for `publishing_from_rss` section in Settings (#13914)

* implement takeover code part 1

* implement takeover code

* fix feed fetch

* need rhymes help

* complete implementation; specs pending

* fix STUPID omission that caused so many headaches 😫

* implement profile fields pointing to users_settings 🎉

* run migrations

* implement inbox type & guidelines takeover code; specs pending (#13911)

* Point changes in notification settings to `users_notification_settings` table (#13910)

* implement takeover code; remains specs

* address PR feedback; remove related sync code

* address PR review feedback

* need help with routing and specs

* address pr review

* addressing pr review

* Treat implementation edge cases and omissions 😅

* fix uncommented comment

* fixing implementation cases

* address more PR review feedback

* fixing notifications use-cases

* refactor settings controller

* more pr review changes

* solving bugs

* fix broken onboarding

* handle eperience_level calls

* more fixes

* remove unneeded mappings

* add To-dos for quety updates

* remove done TODO

* purge done TODOs

* update notification_settings-related queries

* start fixing specs

* fixing specs

* fix notification and lrg_forem specs

* fixing broken specs

* still fixing

* fix line dif and remove reloads from user.rb

* run specs

* silence bullet and other fixes

* remove setting migration scripts and specs, fix more settings for specs

* handle missing user for article builder and fix notification specs

* fix some final controller specs and re-add incorrectly removed specs

* remove deprecated data update scripts and related workers, put travis back

* refactor admin tags mods controller, write/move specs for users notifications settings controller

* schema cleanup and other small refactors for consistency

* set field we can invalidate in spec via active record instead of at the db level

* remove I think an uneccessary hook call from subscribe_to_mailchimp_newsletter

* use bnefore_create to setup settings, please dont blow up the test suite

* mailchimp bot fix

* remove decorator in favor of single model method

Co-authored-by: Arit Amana <msarit@gmail.com>
Co-authored-by: Ridhwana <ridhwana.khan16@gmail.com>
Co-authored-by: Arit Amana <32520970+msarit@users.noreply.github.com>
Co-authored-by: Jamie Gaskins <jamie@forem.com>
2021-07-08 09:31:34 -05:00
Anna Buianova
40b989ca62
Configure badge credits by admins (#13145)
* Added credits_awarded to /admin/badges forms

* Award credits only if badge has them

* Removed information about credits and listings in the new badge email when not needed

* Specs for number of credits awarded for badges

* Added missing newline

* Fix typo

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>

* Improve new_badge_email.text.erb

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>

* Fixed number of credits in notification

* Added specs for number of credits in notifications

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
2021-03-30 10:58:48 +03:00
Andy Zhao
e915f46bf4
Resourcify Badge Achievements (#12832)
* Resourcify badge achievements

* Add test for single resource admin badge achievements

* Add badge and badge achievement roles

* Alphabetize (mostly) and cleanup syntax for easier writing

* Use quotes instead of %w and not outsmart myself :(

* alpha oops
2021-02-27 09:53:46 -05:00
Alex
a5e6f7942c
Rename MarkdownParser to MarkdownProcessor::Parser (#12248)
* Rename MarkdownParser to MarkdownProcessor::Parse

* Wake up, Travis

* Fix typo
2021-01-13 10:39:13 -05:00
rhymes
33dccc7997
Move badges_area template in proper place and refactor the partial (#11400)
* Move badges_area template in proper place and refactor the partial

* Fix badge show routing
2020-11-13 14:23:50 +01:00
rhymes
5a2cae4fbb
Rubocop: enable and fix new Rails cops (#9537)
* Enable new Rails/* cops and use autocorrect on them

* Fixed Rails/PluckInWhere leftovers

* Fix Rails/DefaultScope

* Enable and fix Rails/PluckId

* Fix manual mistake with forcing autocorrection on Rails/PluckId

* Apply PR feedback to remove Rails/PluckId inline disables

* Apply PR feedback to get rid of Rails/PluckInWhere inline
2020-07-29 11:14:19 +02:00
rhymes
2926f6be12
[deploy] Strengthen badge achievement code and fix badge email (#7000)
* Add badges and badge achievements to seeds

* Strengthen BadgeAchievement code and fix mailer bug

* Add indentation
2020-04-02 09:14:10 -04:00
Alex
783da4b0d5
Move BadgeAchievements::SendEmailNotificationWorker to Sidekiq (#5779) [deploy] 2020-01-31 14:45:32 -05:00
serena
252027ad9c use new_badge_achievement_worker instead of active job (#5358) [deploy] 2020-01-07 08:16:17 -05:00
Araslanov Evgeny
02a75b6efa Remove unused methods _without_delay (#4366) [ci skip] 2019-10-16 10:35:49 -04:00
Kartikey Tanna
b16fa4f8cc Implemented ActiveJob for badge_achievements#send_email_notification (#2962)
* Implemented ActiveJob for badge_achievements#send_email_notification

* Sending email only if record not nil

As per the review
2019-05-27 09:44:38 -04:00
Ben Halpern
15ea00328c
Award credits along with badge achievements (#2683) 2019-05-03 15:38:25 -04:00
rhymes
743316b528 Move send new badge achievement notification to ActiveJob (#2474) 2019-04-29 10:51:08 -04:00
cyrillefr
4fd66372dc Enable Layout/AlignParameters (#2340)
Check if the parameters on a multi-line method call or definition are aligned.

Resolves: #2021
2019-04-08 18:47:34 -04:00
Keshav Biswa
8d57d45ecc Rubocop Style cops enabled (#2056)
* Rubocop enabled style/alias

* Enabled Style/ArrayJoin Cop

* Enabled Style/Attr

* Enabled Case Equality

* Enabled CharacterLiteral

*  Enabled ColonMethodCall Cop

* Enabled CommentAnnotation cop

* Enabled PreferredHashMethods Cop

*  Enabled DoubleNegation Cop

* Enabled EachWithObject Cop

* Enabled EmptyLiteral Cop

* Enabled EvenOdd Cop

* Enabled IfWithSemicolon Cop

* Enabled Lambda and LambdaCall Cop

* Enabled LineEndConcatenation Cop

* Enabled ModuleFunction Cop;

* Enable NegatedIf and NegatedWhile Cop

* Enabled NilComparison Cop

* Enabled Not Cop

* Enabled NumericLiterals Cop

* Enabled OneLineConditional Cop

* Enabled PercentLiteralDelimiters Cop

* Excluded internal/users_controller from negated_if cop

* Reverted the double negation change from github_issue_tag and github_issue.rb"

* Enabled PerlBackrefs Cop

* Changed Regexp.last_match(1) to Regexp.last_match(0)

* Enabled proc cop

* Enabled RaiseArgs Cop

* Reverted Regexp.last_match(0) to Regexp.last_match(1)

* Enabled SelfAssignment Cop

* Enabled SingleLineMethods Cop

* Enabled SpecialGlobalVars Cop

* Enabled VariableInterpolation Cop

* Enabled WhenThen Cop

* Enabled WhileUntilModifier Cop

* Enabled WordArray Cop

* Enabled IfUnlessModifier Cop

* Enabled GuardClause Cop
2019-03-15 18:33:54 -04:00
Andy Zhao
0a8f9ca654 Fix URL Validations and Update Admin Dashboard (#1392)
* Validate for trailing slash instead of strict validation

* Remove unused sign_in_count field

* Add profile URLs to edit view

* Add profile URLs to admin controller params

* Add profile URLs to edit view

* Clean up index and search views for user

* Move around user fields to make more sense

* Display more informative label

* Remove name_of_user field in favor of new display label

* Fix typo

* Remove duplication for website, employer, and Mastodon URLs

* Add score to comment params

* Remove unused name_of_user field views

* Fix typo for medium url
2018-12-26 18:00:02 -05:00
Andy Zhao
a1010201f2 Notifications part 2 (#1156)
* Remove stream and add new notification views

* Actually remove Stream

* Move followers query to async method

* Remove unused tests and fix query

* Try using without delay instead

* Add without delay and escape HTML

* Make all tests pending for now
2018-11-19 18:14:24 -05:00
Andy Zhao
2db2dd1e5a WIP Refactor/notifications (#1131)
* Add new columns to notifications table

* Remove stream from notifications and add new methods

* Turn off moderation comment notifications

* Add notifiable_type index to migration

* Stop creation of Stream-based notification model instances

* Add notification model create hooks

* Add badge achievement notification creation hook

* Fix some specs

* Add missing @ symbol

* Fix for tests and rename a few things

* forgot to uncomment code sigh
2018-11-19 16:09:02 -05:00
rhymes
1b60ee5009 Use timezone aware methods (#893)
* Use timezone aware datetime methods

* Use timezone aware date parse for GitHub issue tag

* Introduce a bit of chaos programming using Zonebie

Zonebie uses a random timezone to run tests, it's a really good way to see if the code is timezone dependent or not.

* Convert GitHub issue date as UTC
2018-10-18 16:26:29 -04:00
Arun Kumar
2400908b9d Refactor render_rewarding_context_message_html method with a guard (#569)
clause
2018-07-12 10:58:37 -04:00
Andy Zhao
6dfcf2e856 Fix adding quotes and dashes in codeblocks (#557)
* Fix adding quotes and dashes in codeblocks

* Use find_by for all remove_from_feed methods (#558)

* Destroy memberships when chat channel is destroyed
2018-07-10 13:41:54 -04:00
Ben Halpern
fd4390983c
Add badge achievemnt context message markdown (#382)
* Add badge achievemnt context message markdown

* Add badge rewarder method for beloved comments
2018-06-04 17:31:01 -04:00
Ben Halpern
f073eb5754
Add badges and org cta (#324)
* Make org proof a required field

* Fix color picker and other minor org adjustments

* Add MVP of org add'l sidebar

* Add proof to org factory

* Fix org create action and fix tests

* Add new org fields to admin panel & lint

* Add proof to org edit for backward compatibility

* Add org info to edit preview

* Move preview edit notice to inside article div

* MVP of badge "final" steps

* Add info to user sidebar and clean up badge commit

* Modify sidebar for data

* Add organization decorator

* Add conditional so only users have new swipe nav, not orgs

* Add cloudinary prefix to badges

* Disallow duplicate badges
2018-05-17 18:22:37 -04:00
Mac Siri
1663e7e2c8 Implement Badge & BadgeAchievement model (#273)
* Create migration for Badge & BadgeAchievement

* Create Badge model with spec & BadgeUploader

* Create BadgeAchievement with spec

* Add badges & badge_achievements assoc to User

* Fix typo

* Clean up BadgeUploader

* Remove storage config & Fix lint

* Add allow-duplicate-badge spec
2018-05-07 13:35:16 -04:00