Commit Graph

80 Commits

Author SHA1 Message Date
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
evazion
c7492343ce String: add truthy? & falsy? core extensions.
* Add `truthy?` and `falsy?` core extensions to String.

* Use `truthy?` and `falsy?` to replace ad-hoc parsing of boolean
  parameters in various places.
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
evazion
75cc1421a3 Fix #3590: Superfluous space added on certain autocompletions.
Bug: searching for /wiki_pages?search[title]=touhou%20 didn't find the
'touhou' wiki. The space wasn't stripped when the title was normalized.
2018-03-30 22:24:34 -05: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
BrokenEagle
160829d262 Don't update the updater_id when nothing has changed 2018-01-14 20:15:41 -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
b215d2112d wiki pages: normalize unicode in other names. 2017-08-12 17:15:19 -05:00
evazion
9b031a9c20 Fix #3266: Normalize fullwidth Unicode characters in translated tags. 2017-08-12 17:13:52 -05:00
evazion
1000f8d2e2 Fix #3246: Require nonblank body for wiki pages. 2017-07-29 14:59:42 -05:00
Type-kun
faa2d99160 Fix #3174 2017-06-19 18:22:58 +05:00
evazion
c1834ab8dd Inherit models from ApplicationRecord instead of ActiveRecord::Base. 2017-06-16 13:28:31 -05:00
evazion
c06ae5277e Fix #1608: Show wiki page of alias consequent for Related Tags
Make related tags apply aliases before fetching tags from the wiki page.
2017-06-12 19:52:19 -05:00
evazion
1a52f9db2b wiki pages: add wildcard support to "other names" search. 2017-05-24 14:59:00 -05:00
evazion
7ade3b6831 Fix #2352: return raw usernames in API instead of pretty names. 2017-05-03 22:16:38 -05:00
evazion
30872ebb41 Fix #2990: Wiki Autocomplete Misses On Certain Meta-wikis
/wiki_pages?search[order]=post_count didn't include wiki pages that
didn't belong to a tag. This was due to doing an inner join on the tags
table instead of a left outer join.
2017-04-23 16:55:15 -05:00
Albert Yi
441022960a Merge pull request #2968 from evazion/fix-wiki-rename
Fix #2964: prevent renaming wikis with non-empty tags.
2017-04-10 14:53:33 -07:00
evazion
1b572c592c wikis: disallow renaming unless tag is empty (fix #2964). 2017-04-10 16:40:42 -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
r888888888
80f439f075 fixes #2898: Wiki Page Versions still not recording "is_deleted" 2017-02-27 16:57:24 -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
Albert Yi
e78b7d2a8c fixes #2716: Wiki pages should be undeletable 2016-10-18 15:45:50 -07:00
evazion
c46b31aa9c Prevent reverting to foreign versions (fixes #2711). 2016-10-11 06:57:46 +00:00
r888888888
1d9596d7f2 fixes #2417 2015-06-29 18:17:59 -07:00
Toks
27acbcace7 Make wiki other names case-sensitive 2014-06-16 20:58:48 -04:00
Toks
624f2c704b Add wiki search option for whether other names are present 2014-06-14 14:17:06 -04:00
Toks
10e0311447 #2141 normalize other names 2014-05-24 12:58:14 -04:00
Toks
78387fa168 #2141 hide index in api 2014-05-23 16:33:55 -04:00
Toks
b18bb73f4b Implentation for #2141 2014-05-22 20:07:15 -04:00
r888888888
90f3156a73 fixes #2132 2014-04-17 14:17:11 -07:00
r888888888
fad0ab7c93 fixes #2133 2014-04-16 17:43:34 -07:00
r888888888
ff810a16ba fixes #1897 2014-03-18 13:06:00 -07:00
r888888888
e127e8b6f2 fixes #1977 2013-09-12 15:20:20 -07:00
Toks
eaa6f5b1c7 Exclude deleted artists from showing up on wiki page 2013-08-18 18:24:40 -04:00
Toks
ecfcebe30a Add support for wildcard searches in text fields
#1663
2013-07-20 16:51:55 -04:00
Toks
46aad0d3f1 fixes #1576
The "params[:order] ||= params.delete(:sort)" is to support existing
links using sort.
2013-07-12 13:18:19 -04:00
Toks
395f3d1342 hide index fields from api; closes #1739 2013-06-23 12:12:30 -04:00
Toks
daebcf19f0 fix wiki page xml api 2013-06-23 12:01:07 -04:00
Toks
168de3215f fixes #1754; include category in wiki page api 2013-06-23 11:42:55 -04:00
ToksT
83f76012ea fixes #1514 2013-05-31 23:05:43 -04:00
Toks
d99e9c5d81 fixes #1561 2013-05-20 08:42:15 -04:00
r888888888
49de333b74 fixes #1579 2013-05-07 17:58:27 -07:00
r888888888
5a1a3baa1c fixes #1514 2013-05-07 17:33:33 -07:00
Toks
5a04bc30ba fixes #976 2013-04-05 16:58:50 -04:00
Toks
af44e99130 adds more user class support 2013-03-31 22:02:53 -04:00
albert
cb1b021c2c fixes #1136 (and a few other cases) 2013-03-30 11:51:17 -04:00
albert
85a5fcc658 fixes #1133 2013-03-29 16:45:59 -04:00
albert
733fa2dd7b fixes #1028 2013-03-22 09:17:55 -07:00
albert
277c918062 fix wiki page api 2013-03-20 21:30:24 -07:00