Commit Graph

55 Commits

Author SHA1 Message Date
evazion
07e23204b6 rubocop: fix various Rubocop warnings. 2021-06-17 04:17:53 -05:00
evazion
e23f09235e artists: redact version histories of banned artists.
Fix names and urls of banned artists being visible in Google through
artist version pages.
2021-02-07 23:28:50 -06:00
evazion
ee4516f5fe searchable: refactor searchable_includes.
Pass searchable associations directly to search_attributes instead of
defining them separately in searchable_includes.
2020-12-16 23:57:07 -06:00
evazion
e771c0fca8 searchable: don't automatically include id, created_at, updated_at.
Don't make search methods on models call super in order to search
certain default attributes (id, created_at, updated_at). Simplifies some
magic.
2020-12-16 23:57:07 -06:00
BrokenEagle
c9ba41a58e Add additional search options 2020-07-27 19:29:19 +00:00
BrokenEagle
c4009efccd Convert models to use new search includes mechanism 2020-07-27 19:29:18 +00:00
BrokenEagle
e23ee170f5 Add alternate comparison types to versions
- The types are:
-- Previous: The default and the previously used type
-- Subsequent: Compares against the next version
-- Current: Compares against the current version
- Allow switching between comparison types in index and diff views
-- Have links vary depending upon current comparison type
2020-03-17 18:31:20 +00:00
evazion
cb11d818b1 artist versions: fixup is_active reference. 2020-03-09 14:40:22 -05:00
evazion
4c11e339bd artists: rename is_active flag to is_deleted.
Rename is_active to is_deleted. This is for better consistency with
other models, and to reduce confusion over what "active" means for
artists. Sometimes users think active is for whether the artist is
actively producing work.
2020-03-06 14:50:21 -06:00
BrokenEagle
63b3503bfc Add ability to use nested only parameter
- The only string works much the same as before with its comma separation
-- Nested includes are indicated with square brackets "[ ]"
-- The nested include is the value immediately preceding the square brackets
-- The only string is the comma separated string inside those brackets
- Default includes are split between format types when necessary
-- This prevents unnecessary includes from being added on page load
- Available includes are those items which are allowed to be accessible to the user
-- Some aren't because they are sensitive, such as the creator of a flag
-- Some aren't because the number of associated items is too large
- The amount of times the same model can be included to prevent recursions
-- One exception is the root model may include the same model once
--- e.g. the user model can include the inviter which is also the user model
-- Another exception is if the include is a has_many association
--- e.g. artist urls can include the artist, and then artist urls again
2020-02-12 23:58:53 +00:00
BrokenEagle
7b1efd1204 Rework artist versions index view
- Added a changes column explicitly listing all of the changes
-- This makes it more in line with the other version views now
- Does a symmetric difference on the array fields to detect changes
2020-02-08 22:57:29 +00:00
BrokenEagle
76dcccb7de Alter previous method on all versions models
This is to prevent redoing the same SQL query which wasn't being cached.
2020-02-08 16:14:51 +00:00
evazion
ea45e44e10 search: remove legacy 'search[sort]' params.
Remove support for the `search[sort]` param on certain index pages. This
hasn't been used for years, and it caused the `search[order]=` param to
be added to pagination links even when the order was blank.
2020-01-31 02:43:08 -06:00
evazion
6b066f2cab Fix #4275: Unable to update "banned artist" entries.
Allow all users to view and edit artist entries and wiki pages belonging
to banned artists. There was little need to hide these pages from
Members, it was mainly to appease artists who didn't like us even
linking to their sites.

These restrictions also had multiple flaws:

* Banned artist information was still visible in the API.
* It was still possible to edit banned artists using the API.
* It was still possible for unprivileged users to revert banned
  artist entries or wiki pages to previous versions.
* The restrictions were inconsistent: in various places they were
  either Member-only, Gold-only, or Builder-only.
2020-01-31 02:43:08 -06:00
evazion
895199ecfc models: include all int/bool columns as html data attributes by default. 2020-01-05 22:57:47 -06:00
BrokenEagle
223a6df5d8 Add API data to show/index views 2020-01-04 22:02:44 +00:00
evazion
67100f26eb Fix #4149: Add missing post search options on applicable models. 2019-09-01 13:10:37 -05:00
evazion
7b8584e3b0 Model#search: refactor searching for attributes. 2019-08-29 20:44:33 -05:00
evazion
c3ad7f6112 Model#search: factor out username search. 2019-08-29 20:44:27 -05:00
evazion
9a3e9747d8 users: replace scopes with associations. 2019-08-29 20:42:50 -05:00
evazion
e25e8d564a artist versions: refactor diffs. 2018-12-07 12:45:51 -06:00
evazion
41ff05c121 artists: convert other_names to array (#3987). 2018-11-15 14:31:16 -06:00
evazion
741462ae68 artist versions: convert other_names, url_string to arrays (#3987). 2018-11-14 14:25:02 -06:00
evazion
03abbd0683 Fix #2894: Use [[:space:]] instead of \s in regexes. 2018-09-20 19:24:38 -05:00
evazion
99a5e885e0 artist_url.rb: remove legacy artist url normalization code.
* `legacy_normalize` came from c6012535, which is no longer a problem.

* `normalize_for_search` is only used for "[mass edit]" links
in artist entries. These links are a shortcut for performing a
`-artist_name source:<artist_url> -> artist_name` mass edit to tag
untagged artists, but this won't work for most sites these days.
2018-09-07 12:55:51 -05: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
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
7ade3b6831 Fix #2352: return raw usernames in API instead of pretty names. 2017-05-03 22:16:38 -05:00
Type-kun
8998babd41 Fix #2665: nil exception in /artist_versions 2016-09-10 00:40:17 +05:00
Type-kun
23f4232bd2 Style obsolete artist changes (fixes #1171) 2016-08-28 23:12:35 +05:00
r888888888
b8f14b6fee hide more pages for banned artists #2132 2016-01-27 17:06:13 -08:00
Toks
c601253553 Don't make pixiv http requests when displaying artist history
The reason the urls need to be normalized at all here is because legacy
urls from Danbooru 1 don't have their unnormalized counterparts stored
anywhere and thus can't be accurately compared with unnormalized urls
from Danbooru 2.
2014-12-09 17:23:44 -05:00
r888888888
fad0ab7c93 fixes #2133 2014-04-16 17:43:34 -07:00
Toks
46fba0f35b fixes #1945 2013-08-18 19:19:54 -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
c250501bc4 add artist version search 2013-05-17 14:46:00 -04:00
Toks
0143401ac3 fixes #1332; partial fix for #1378 2013-04-20 10:41:46 -04:00
Toks
a3c06044af reorganize artist version search methods 2013-04-14 18:16:55 -04:00
Toks
eed6ece3ec adds missing updaters
to forum posts, comments, and artist versions
2013-03-30 12:04:57 -04:00
albert
4f8cd6006c fixes for source pattern search, fixed tests 2013-03-29 11:28:01 -04:00
Toks
7e3324b5f0 fixes #858
adds color coding to both urls and other names on artist versions
2013-03-29 09:59:14 -04:00
小太
cba839ba76 Kill trailing whitespace in ruby files 2013-03-19 23:10:10 +11:00
albert
9446343bd7 fixes #838 2013-03-12 12:53:24 -04:00
albert
78f1d0f69a fixes to user search 2013-02-21 12:42:41 -05:00
albert
c7ffda81bf improved artist test 2013-01-11 16:38:06 -05:00
albert
8749c43b3e refactored search 2013-01-10 17:45:52 -05:00