Change kudo uniqueness validation to use users instead of pseuds

Description

Update the Rails uniqueness validator on kudos to use user_id instead of pseud_id.

We won't clean up the duplicates in the database just yet, and as before people will still be able to get past this check on a dodgy connection, but it will be harder to leave duplicates from the same user (even when changing default pseuds).

When we do add the uniqueness constraint at the database level, we'll have the error handling ready at the application level (people will see "left kudos here " as usual).

For the rare cases where users can get past the Rails validation and run into the (future) database constraint, we should catch ActiveRecord::RecordNotUnique exceptions, similar to what we do on user creations: https://github.com/otwcode/otwarchive/blob/57e7cab589abc7cc666ddf4d3abe768d801b3493/app/controllers/users_controller.rb#L9-L24.

How to test:

  • Check that leaving logged in kudos still works.

  • Check that leaving logged in kudos a second time on the same work will get you the "left kudos here " message.

  • Check that you can no longer leave logged in kudos after changing default pseuds.

Environment

None

Assignee

redsummernight

Reporter

redsummernight

Roadmap

Misc

Priority

Medium

Affects versions

Fix versions

Components

BackEnd

Difficulty

Medium

Required Access Level

None

Milestone

Internal 0.9
Configure