Commit Graph

71 Commits

Author SHA1 Message Date
evazion
a926b162be models: drop unnecessary presence validations.
In rails 5, belongs_to associations automatically validate that the
associated item is present, meaning that we don't need to validate these
things manually any more.
2019-08-04 14:40:37 -05:00
Albert Yi
04edc3f533 update factories + tests 2019-05-10 17:31:07 -07:00
evazion
37b2214472 post_tags_match: replace joins with subqueries.
Refactor various post_tag_match methods to use subqueries instead of joins.

This simplifies things inside PostQueryBuilder, since now we can assume
we're always dealing with a Post relation, rather than some other table
joined with the posts table.
2018-12-11 18:10:20 -06:00
evazion
f5012464ab Fix #3965: Extraneous API attributes.
Remove the updater_id/updater_ip_addr virtual attributes from
pools/notes. Juss pass them in as params to create_version instead.
2018-10-30 15:41:17 -05:00
evazion
0eff095a3e Refactor searching text attributes.
* Allow using ApplicationRecord#attribute_matches to search text attributes,
and standardize models on using this instead of duplicating code.

* Remove restrictions that limited wildcard searches to Builders only in various places.
2018-08-31 19:50:46 -05:00
Albert Yi
72f319ccf3 rename lambda references to use shorthand syntax 2018-05-10 11:18:02 -07:00
evazion
216d735f24 Fix #3696: API: handle boolean params consistently
* Use ApplicationRecord#attribute_matches to handle boolean attributes
  consistently in search methods.

* Add support for searching various boolean attributes that previously
  weren't supported.
2018-05-03 19:57:14 -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
BrokenEagle
d829ab3a00 Move all order logic to models
- Have a default order for each model
-- The overall default is ID DESC
- Allow for custom orderings
-- When comma-separated IDs are used
2018-01-29 11:42:53 -08:00
evazion
0ca726802f Fix #3430: Accept the search[id] param in all controllers.
* Allow every controller to take the `search[id]` param.

* Parse the `search[id]` param the same way that the `id:<N>` metatag is
  parsed. So `search[id]=1,2,3`, `search[id]=<42`, `search[id]=1..10`, for
  example, are all accepted.
2017-12-17 17:36:52 -06:00
evazion
fd9dc6f647 expunge: decrement upload and note/post update counts (fix #2062). 2017-09-13 13:29:35 -07:00
evazion
4b635628cc Fix #3243: Don't create new note versions when nothing is changed. 2017-07-28 17:41:05 -05:00
evazion
c1834ab8dd Inherit models from ApplicationRecord instead of ActiveRecord::Base. 2017-06-16 13:28:31 -05:00
evazion
02b3622f12 api: allow search[*_id] params to accept lists of ids in more places. 2017-05-23 15:45:40 -05:00
evazion
9f1096e67f post replacement: rescale notes. 2017-05-17 00:14:41 -05:00
evazion
7ade3b6831 Fix #2352: return raw usernames in API instead of pretty names. 2017-05-03 22:16:38 -05:00
evazion
a3ecfdb79d notes: disallow blank note bodies. 2017-04-28 19:34:27 -05:00
Albert Yi
1c837aba6e Merge pull request #2879 from evazion/fix-dead-code
Eliminate dead code
2017-02-07 13:56:05 -08:00
evazion
ec653dce71 app/presenters: remove unused forum_post/note/post_version presenters. 2017-02-06 19:07:02 -06:00
evazion
35b3398142 post_test.rb: add more metatag search tests. 2017-02-06 18:48:39 -06:00
evazion
e98e7f1ea7 Fix note_update_count increment test.
5) Failure:
NoteTest#test_: In all cases updating a note should increment the updater's note_update_count. [/home/danbooru/src/danbooru/test/unit/note_test.rb:113]:
"CurrentUser.note_update_count" didn't change by 1.
Expected: 1
  Actual: 0
2017-02-03 04:03:44 -06:00
r888888888
237c997ae1 remove usage of increment! #2835 2017-01-17 15:46:21 -08:00
Albert Yi
79842f7a3b restrict min level constraints for forum topics to mod+admin and restrict options based on current user's level. check privileges for visiblity in forum posts and topics. deprecate serializable_hash (undocumented, internal) for as_json, refactor to use hidden_attributes and method_attributes #2658 2016-10-25 15:05:55 -07:00
evazion
c46b31aa9c Prevent reverting to foreign versions (fixes #2711). 2016-10-11 06:57:46 +00:00
Toks
6fe1a69e8e Don't merge note versions on deletion 2015-10-30 12:19:35 -04:00
Toks
aa9deb26e8 fixes #2512, fixes #2513 2015-09-09 00:20:19 -04:00
r888888888
341b29ce41 fix tests 2015-08-18 17:40:53 -07:00
r888888888
65d52ebb40 fixes #1897: the "version" field will be updated even when versions are merged 2015-08-06 15:21:06 -07:00
Toks
bdb5bb49da fix #2334 2015-01-15 13:15:56 -05:00
Toks
325fc3e864 fixes #2154 2015-01-03 14:13:53 -05:00
Toks
1b812f31f1 fixes #2226 2014-07-16 11:47:37 -04:00
Toks
772003a55a fixes #2217 2014-07-06 12:03:48 -04:00
r888888888
fad0ab7c93 fixes #2133 2014-04-16 17:43:34 -07:00
r888888888
71e3b1f928 fixes #1897 2014-03-18 12:56:36 -07:00
Toks
5d5caf5eea fixes #2102 2014-02-28 19:02:30 -05:00
Toks
81aa294b38 add Note#for_creator, Pool#name_matches 2013-12-07 22:05:42 -05:00
Toks
ecfcebe30a Add support for wildcard searches in text fields
#1663
2013-07-20 16:51:55 -04:00
Toks
d5d5235d9a simplify xml api methods 2013-06-23 12:12:51 -04:00
Toks
395f3d1342 hide index fields from api; closes #1739 2013-06-23 12:12:30 -04:00
Toks
e9593dd975 fixes #1664 2013-05-23 23:20:22 -04:00
Toks
ad60ae1739 Revert "fixes #1648"
This reverts commit a11bcf4dbd.
2013-05-20 20:35:29 -04:00
Lightforger
a11bcf4dbd fixes #1648 2013-05-21 03:17:18 +03:00
Toks
17af05b2b1 fixes #720 2013-05-18 16:25:46 -04:00
Toks
1a743356ce fixes #1396; expand tests 2013-05-06 20:01:34 -04:00
r888888888
ce10a72bb6 fixes #1396, fix tests 2013-05-03 17:29:41 -07:00
albert
4dcc21a97a fixes #948 2013-03-22 10:47:24 -07:00
albert
733fa2dd7b fixes #1028 2013-03-22 09:17:55 -07:00
小太
cba839ba76 Kill trailing whitespace in ruby files 2013-03-19 23:10:10 +11:00
albert
7b5a73a2d2 fixes #931 2013-03-18 09:33:45 -07:00
albert
c5ce14ac68 fixes #837 2013-03-11 13:14:25 -04:00