Commit Graph

55 Commits

Author SHA1 Message Date
evazion
0df5c0fd2b Replace deprecated update_attributes with update.
https://rubyinrails.com/2019/04/09/rails-6-1-activerecord-deprecates-update-attributes-methods/

DEPRECATION WARNING: update_attributes! is deprecated and will be removed from Rails 6.1 (please, use update! instead)
2019-08-25 20:29:32 -05:00
evazion
44653fb722 Fix errors on /artists/show_or_new, /wiki_pages/show_or_new pages.
Fix these pages to redirect to the new page instead of erroring out when
a name or title isn't given.
2019-08-22 00:09:50 -05:00
evazion
59b277ead1 users: drop id_to_name, name_to_id caching.
Changes:

* Drop Users.id_to_name.
* Don't cache Users.name_to_id.
* Replace calls to name_to_id with find_by_name when possible.
* Don't autodefine creator_name in belongs_to_creator.
* Don't autodefine updater_name in belongs_to_updater.
* Instead manually define creator_name / updater_name only on models that need
  to return these fields in the api.

id_to_name was cached to reduce the impact of N+1 query patterns in
certain places, especially in api responses that return creator_name /
updater_name fields. But it still meant we were doing N calls to
memcache. Using `includes` to prefetch users avoids this N+1 pattern.

name_to_id had no need be cached, it was never used in any performance-
sensitive contexts.

Avoiding caching also avoids the need to keep these caches consistent.
2019-08-18 11:24:42 -05:00
evazion
bb157f5d5b models: drop various unused #named methods. 2019-08-15 19:18:19 -05:00
evazion
0f98631908 wiki pages: fix error in /wiki_pages/does_not_exist.json 2019-08-13 21:30:21 -05:00
evazion
308a5021b4 wiki pages: convert other_names to array (#3987). 2018-11-13 19:18:11 -06:00
Albert Yi
abcef9115b fix tests 2018-07-20 13:52:56 -07:00
Albert Yi
93f52adc81 fixes #3768 2018-07-20 11:51:42 -07:00
Albert Yi
da34c95da5 add expiry parameter 2018-05-22 14:57:46 -07:00
Albert Yi
72d72fd3d0 eliminate usage of localstorage to cache tag autocomplete results (fixes #3543) 2018-05-17 09:54:37 -07:00
evazion
af02113e3c /wiki_pages/new: fix "param is missing or the value is empty: wiki_page" 2018-04-12 21:31:34 -05:00
r888888888
abce4d2551 Raise error on unpermitted params.
Fail loudly if we forget to whitelist a param instead of silently
ignoring it.

misc models: convert to strong params.

artist commentaries: convert to strong params.

* Disallow changing or setting post_id to a nonexistent post.

artists: convert to strong params.

* Disallow setting `is_banned` in create/update actions. Changing it
  this way instead of with the ban/unban actions would leave the artist in
  a partially banned state.

bans: convert to strong params.

* Disallow changing the user_id after the ban has been created.

comments: convert to strong params.

favorite groups: convert to strong params.

news updates: convert to strong params.

post appeals: convert to strong params.

post flags: convert to strong params.

* Disallow users from setting the `is_deleted` / `is_resolved` flags.

ip bans: convert to strong params.

user feedbacks: convert to strong params.

* Disallow users from setting `disable_dmail_notification` when creating feedbacks.
* Disallow changing the user_id after the feedback has been created.

notes: convert to strong params.

wiki pages: convert to strong params.

* Also fix non-Builders being able to delete wiki pages.

saved searches: convert to strong params.

pools: convert to strong params.

* Disallow setting `post_count` or `is_deleted` in create/update actions.

janitor trials: convert to strong params.

post disapprovals: convert to strong params.

* Factor out quick-mod bar to shared partial.
* Fix quick-mod bar to use `Post#is_approvable?` to determine visibility
  of Approve button.

dmail filters: convert to strong params.

password resets: convert to strong params.

user name change requests: convert to strong params.

posts: convert to strong params.

users: convert to strong params.

* Disallow setting password_hash, last_logged_in_at, last_forum_read_at,
  has_mail, and dmail_filter_attributes[user_id].

* Remove initialize_default_image_size (dead code).

uploads: convert to strong params.

* Remove `initialize_status` because status already defaults to pending
  in the database.

tag aliases/implications: convert to strong params.

tags: convert to strong params.

forum posts: convert to strong params.

* Disallow changing the topic_id after creating the post.
* Disallow setting is_deleted (destroy/undelete actions should be used instead).
* Remove is_sticky / is_locked (nonexistent attributes).

forum topics: convert to strong params.

* merges https://github.com/evazion/danbooru/tree/wip-rails-5.1
* lock pg gem to 0.21 (1.0.0 is incompatible with rails 5.1.4)
* switch to factorybot and change all references

Co-authored-by: r888888888 <r888888888@gmail.com>
Co-authored-by: evazion <noizave@gmail.com>

add diffs
2018-04-06 18:09:57 -07:00
evazion
bef02e0ac1 /wiki_pages/search: make available to anonymous users. 2017-07-06 19:12:17 -05:00
evazion
b9693827c3 /wiki_pages: sort autocomplete by post count.
* Add search[order]=post_count param to /wiki_pages.
* Make autocomplete do a prefix match ordered by post count, so that it
  works the same way that tag autocomplete does elsewhere.
2017-04-07 18:25:31 -05:00
evazion
85a39cadf0 /wiki_pages: avoid unnecessary COUNT(*).
@wiki_pages.count issues a COUNT(*), which is unnecessary when we're
just counting the ~20 @wiki_pages we've already loaded.
2017-04-07 18:10:26 -05:00
evazion
40092f21ba Remove redundant rescue_from calls.
These are redundant because ApplicationController rescues these exceptions already.
2017-02-25 02:18:16 -06:00
r888888888
291e9acdc7 fixes #2885: "Is Deleted" not being recorded correctly for Wiki Page Versions 2017-02-15 15:32:41 -08:00
Albert Yi
e78b7d2a8c fixes #2716: Wiki pages should be undeletable 2016-10-18 15:45:50 -07:00
Albert Yi
2a5343b8cf add more intelligent js for artist forms 2016-10-18 14:56:40 -07:00
evazion
c46b31aa9c Prevent reverting to foreign versions (fixes #2711). 2016-10-11 06:57:46 +00:00
Toks
551c70d00d If wiki search returns no results automatically do a wildcard search 2015-11-13 01:39:20 -05:00
Toks
814b4b2236 #1579: Also fix when user is searching for wiki that doesn't exist 2015-09-05 22:20:40 -04:00
r888888888
1d9596d7f2 fixes #2417 2015-06-29 18:17:59 -07:00
Toks
f6eb27d3c8 fixes #2177 2014-06-06 20:43:20 -04:00
r888888888
5e3ec6a678 fixes #1445 2014-03-06 19:02:54 -08:00
Toks
0fb0a7564d Fix artist link for wiki show-or-new page 2013-10-25 13:14:31 -04:00
Toks
a70fce91c0 add artist link on new wiki pages 2013-07-07 19:56:59 -04:00
Toks
9ccf1e0f8f add limit parameter to everything 2013-05-15 01:01:19 -04:00
r888888888
050d231375 revert 3ee20d2 2013-05-13 10:48:12 -07:00
Toks
3ee20d2bb7 fixes #846 2013-05-11 16:01:19 -04:00
Toks
299fc1057e fix wiki page errors 2013-05-11 08:37:00 -04:00
Toks
f972ee53c0 enhance show or new wpages; move wpage preview code to helper 2013-05-11 08:31:03 -04:00
r888888888
49de333b74 fixes #1579 2013-05-07 17:58:27 -07:00
r888888888
d1e843390f fixes #1362 2013-04-19 15:37:18 -07:00
albert
541dabaaf6 fixes #1108 2013-03-29 15:37:28 -04:00
albert
364c6fd329 fixes #971 2013-03-22 10:28:32 -07:00
albert
87edfd52b1 fixes #975 2013-03-22 10:24:01 -07:00
albert
e01dfc010a fixes #986 2013-03-20 00:14:26 -07:00
小太
cba839ba76 Kill trailing whitespace in ruby files 2013-03-19 23:10:10 +11:00
albert
c59afe4726 fixes #944 2013-03-18 22:02:03 -07:00
albert
34d7e337ac fixes #911 2013-03-17 21:27:17 -04:00
albert
95e8f02478 handle some common error cases 2013-03-15 15:18:43 -04:00
albert
92eb226c4a fixes #819 2013-03-10 14:51:46 -04:00
albert
56dd8707fd controller tweaks 2013-02-23 15:58:21 -05:00
albert
78f1d0f69a fixes to user search 2013-02-21 12:42:41 -05:00
albert
8749c43b3e refactored search 2013-01-10 17:45:52 -05:00
albert
20639a001e fixes #163: Linking to wiki pages yield an error 2011-10-26 18:41:12 -04:00
albert
5444ad5107 fix dtext styles 2011-10-22 17:23:33 -04:00
albert
a16dfdf0dd fixes 2011-07-09 03:32:18 -04:00
albert
969185ad24 work 2011-05-26 19:10:08 -04:00