Commit Graph

100 Commits

Author SHA1 Message Date
evazion
07e23204b6 rubocop: fix various Rubocop warnings. 2021-06-17 04:17:53 -05:00
evazion
dbb66ace90 routes: replace hardcoded routes in models with route helpers.
Add a Routes module that gives models access to route helpers outside of
views, and use it to replace various hardcoded routes.
2020-12-24 00:17:19 -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
evazion
8d87b1a0c0 models: fix deprecated errors[:base] << "message" calls.
Replace the idiom `errors[:base] << "message"` with
`errors.add(:base, "message")`. The former is deprecated in Rails 6.1.
2020-12-13 04:10:48 -06:00
evazion
8a52d8ed5f BURs: remove dead error handling code.
This is a 'this should never happen' error. This error is only raised if
we add a new bulk update request type and forget to handle it somewhere.
2020-12-03 17:15:24 -06:00
evazion
35d26e92e9 BURs: don't update OP when approving BUR.
When approving or rejecting a BUR, don't edit the OP forum post to add
an EDIT: line stating the request has been approved. Instead just let
the embedded BUR state who it was approved by, and post a reply saying
that the request has been approved.
2020-12-03 17:15:24 -06:00
evazion
6275e85148 BURs: refactor implication wiki page validations.
Move the validation that the tags in an implication must have wiki pages
back into the TagImplication model. Use validation contexts to only run
the validation when the BUR is created, not when the BUR is approved.
2020-12-02 14:30:18 -06:00
evazion
7f90bc4216 BURs: remove ability to skip secondary validations.
Remove the ability to skip secondary validations when creating a BUR.
The only skippable validation that still existed was the requirement
that both tags in an implication must have wiki pages. It's now
mandatory to write wiki pages for tags before you can request an
implication. This doesn't apply to empty tags.
2020-11-12 20:15:14 -06:00
evazion
d9085877be BURs: fix normalization of uppercase characters in scripts.
Only downcase tags in aliases, implications, and category change
commands. Don't downcase mass update commands. Mass updates are
potentially case sensitive (for example: `mass update source:imageboard -> source:Imageboard`).
2020-08-24 17:54:53 -05:00
evazion
1ddcc661e1 BURs: clean up parsing and error handling.
* Don't raise exceptions when a BUR is invalid. Instead, use Rails
  validations to return errors. Fixes invalid BURs potentially raising
  exceptions in views. Also makes it so that each error in a BUR is
  reported, not just the first one.

* Revalidate the BUR whenever the script is edited, not just when the
  BUR is created. Ensures the BUR can't be broken by editing. Fixes a bug
  where forum threads could be broken by someone editing a BUR and
  breaking the syntax, thereby causing the BUR to raise an unparseable
  script error when the forum thread was viewed.

* Validate that removed aliases and implication actually exist.

* Validate that the tag actually exists when changing a tag's category.

* Combine bulk update request processor unit tests with main bulk update
  request unit tests.
2020-08-24 17:10:48 -05:00
BrokenEagle
c4009efccd Convert models to use new search includes mechanism 2020-07-27 19:29:18 +00:00
evazion
d136a12a65 Fix #4359: Allow builders to move small (artist) tags manually.
Allow builders to approve artist alias BURs. The BUR must contain only
artist aliases or mass updates and each artist must have less than 100
posts.
2020-05-11 00:37:37 -05:00
evazion
49383d393a BURs: rename AliasAndImplicationImporter to BulkUpdateRequestProcessor.
The name AliasAndImplicationImporter is a holdover from the time before
bulk update requests existed. This was a bad name because it doesn't do
any actual importing, instead it's used for parsing and executing bulk
update requests.
2020-05-10 22:18:47 -05:00
evazion
71a3cc89fd BURs: don't try to move wikis/artists twice.
* Remove unnecessary rename_aliased_pages option. This option was always enabled.
* Don't try to rename the artist and wiki page inside AliasAndImplicationImporter
  when an alias is approved. This is already handled by TagAlias#process!.
2020-05-10 21:22:22 -05:00
evazion
5feb29ba57 Fix #4441: BUR form: display original request in the error page. 2020-05-04 03:39:41 -05:00
evazion
12d83408ab BURs: make the reason required. 2020-05-04 03:39:41 -05:00
evazion
08fe1c453c BURs: remove "Reason: " prefix from forum posts.
Don't automatically prepend "Reason: " in front of the BUR reason since
this isn't always desirable.
2020-05-04 03:39:41 -05:00
evazion
d5a7fafca1 posts/index: fix several "This tag is under discussion" issues.
Several fixes for the "This tag is under discussion" notice on the post
index page:

* Fix the notice appearing for BURs that aren't pending.
* Fix the notice never going away because of the cache never expiring.
* List all topics when a tag is involved in multiple BURs.
* Link to the forum post instead of the forum topic (fix #4421).
* Optimization: don't check for BURs when the search isn't a simple
  single tag search.
* Add a `tags` field to the bulk update requests table for tracking all
  tags involved in the request (excluding tags in mass updates that are
  negated/optional/wildcards). Known issue: doesn't handle tag type
  prefixes in mass updates correctly (e.g. `mass update foo -> artist:bar`
  doesn't detect the tag `bar`).
* Allow searching the /bulk_update_requests page by tags.

We don't really need to cache the notice here, but we do it anyway to
reduce queries on the post index page.
2020-04-27 19:11:47 -05:00
evazion
79a365abe0 pundit: convert bulk update requests to pundit. 2020-03-20 18:03:00 -05:00
evazion
db63b6d44f pundit: convert forum topics / forum posts to pundit.
Fix it being possible for users to delete or undelete their own forum
posts and topics, even if they were deleted by a mod.
2020-03-20 18:03:00 -05:00
BrokenEagle
09445cb28b Drop unused BUR title column 2020-03-18 23:16:43 +00:00
BrokenEagle
c16ad4f126 Add additional checks for BURs on forum topics 2020-03-18 23:05:12 +00:00
evazion
8253df84d9 forum: make status labels into clickable filters.
* Make it so that you can click the stickied / locked / deleted icons or
  the new / approved / pending / rejected labels to filter topics by
  that status.

* Replace the `mod_only` search param with `is_private`.
2020-03-16 21:23:27 -05:00
evazion
6fecf5db0e BURs: remove old single alias/implication pruning code.
* Rename TagChangeRequestPruner to BulkUpdateRequestPruner.
* Remove old code for pruning individual alias / implication requests.
2020-03-10 21:23:46 -05:00
evazion
be585060f4 BURs: don't add [APPROVED] / [REJECTED] tags to titles. 2020-03-10 21:02:12 -05:00
evazion
0e7632ed8a aliases/implications: remove forum topic updating code.
Remove code for updating forum topics when an alias or implication is
approved or rejected. This code was only used when approving single
alias or implication requests. This is no longer used now that all
alias/implication requests are done through BURs.
2020-03-10 20:55:20 -05:00
evazion
e47d0e0d05 models: set more creator names explicitly.
Set creators explicitly for bans, BURs, comment votes, and posts.
2020-02-23 17:26:08 -06:00
evazion
c1f7b76bdb dtext: refactor parsing of embedded BUR pseudo tags. 2020-02-22 01:37:12 -06:00
evazion
5817af4014 burs/show: remove BUR update count estimate.
Remove the post update count estimate from BUR show pages. This was
complex, slow, and usually inaccurate since it assumed that requests in
a BUR had no overlap with each other, which usually wasn't the case.
2020-02-16 19:21:56 -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
evazion
1aadd19663 BURs: fix broken [bur:<id>] links in forum posts.
Fix bulk update requests generating invalid [bur:<id>] links in forum
posts. The id was missing because the BUR created the forum topic in a
before_create hook, which created the post before the BUR was saved so
the BUR didn't have an id yet. Fix regression caused by b4ce2d83.
2020-01-21 19:56:04 -06:00
evazion
b4ce2d83a6 models: remove belongs_to_creator macro.
The belongs_to_creator macro was used to initialize the creator_id field
to the CurrentUser. This made tests complicated because it meant you had
to create and set the current user every time you wanted to create an
object, when lead to the current user being set over and over again. It
also meant you had to constantly be aware of what the CurrentUser was in
many different contexts, which was often confusing. Setting creators
explicitly simplifies everything greatly.
2020-01-21 00:09:38 -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
309821bf73 rubocop: fix various style issues. 2019-12-22 21:23:37 -06:00
evazion
2bffad9311 BURs: credit tag edits to DanbooruBot.
Credit tag edits that are performed as part of an alias, implication, or
mass update to DanbooruBot instead of the admin who approved the BUR.
2019-12-06 22:54:08 -06: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
9163b3cb1c validations: drop superfluous return statements.
Returning true or false in a validation callback doesn't do anything, so
drop these superfluous return statements.
2019-08-04 15:45:05 -05:00
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
1550538dc1 Tag change notices
This adds a small notice at the bottom of post searches if a single tag search is the target of any tag change request.
2019-01-22 17:22:07 -08:00
evazion
a284d3fb4a BURs: allow only pending BURs to be rejected.
Fix it being possible to reject approved BURs, or to re-reject already
rejected BURs.

Rejecting an approved BUR wouldn't revert the aliases/implications, but
it would change the BUR's status to rejected.
2019-01-15 21:20:28 -06:00
Albert Yi
f33b23d035 add post count estimates for bulk update requests 2019-01-09 15:54:55 -08:00
Albert Yi
8b0af19f7f fixes #3824: render tag requests dynamically in the forum post
refactoring
2019-01-08 12:57:37 -08: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
13fda08fd9 fixes #3712 2018-05-15 14:47:14 -07:00
Albert Yi
8b16934aaa skip pixiv-related tests that throw networking errors 2018-05-15 10:19:20 -07:00
Albert Yi
72f319ccf3 rename lambda references to use shorthand syntax 2018-05-10 11:18:02 -07:00