Skip to content

Commit

Permalink
Merge branch 'main' into rails-7-2-2-1
Browse files Browse the repository at this point in the history
  • Loading branch information
nimmolo committed Jan 4, 2025
2 parents c458514 + 9df2c02 commit 81dc3b0
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 95 deletions.
10 changes: 8 additions & 2 deletions app/helpers/tabs/observations_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,20 @@ def observations_at_where_tabs(query)
# these are from the observations form
def define_location_tab(query)
[:list_observations_location_define.l,
add_query_param(new_location_path(where: query.params[:user_where])),
add_query_param(new_location_path(where: where_param(query.params))),
{ class: tab_id(__method__.to_s) }]
end

# Hack to use the :locations param if it's present and the :user_where
# param is missing.
def where_param(query_params)
query_params[:user_where] || params[:where]
end

def assign_undefined_location_tab(query)
[:list_observations_location_merge.l,
add_query_param(matching_locations_for_observations_path(
where: query.params[:user_where]
where: where_param(query.params)
)),
{ class: tab_id(__method__.to_s) }]
end
Expand Down
7 changes: 1 addition & 6 deletions app/models/field_slip_job_tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ class FieldSlipJobTracker < AbstractModel
SUBDIR = "shared"
PDF_DIR = PUBLIC_DIR + SUBDIR

enum status:
{
Starting: 1,
Processing: 2,
Done: 3
}
enum :status, { Starting: 1, Processing: 2, Done: 3 }

belongs_to :user

Expand Down
12 changes: 3 additions & 9 deletions app/models/location_description.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,10 @@
class LocationDescription < Description
require "acts_as_versioned"

# enum definitions for use by simple_enum gem
# Do not change the integer associated with a value
enum source_type:
{
public: 1,
foreign: 2,
project: 3,
source: 4,
user: 5
}, _suffix: :source
enum :source_type,
{ public: 1, foreign: 2, project: 3, source: 4, user: 5 },
suffix: :source, instance_methods: false

belongs_to :license
belongs_to :location
Expand Down
1 change: 0 additions & 1 deletion app/models/name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ class Name < AbstractModel
extend Parse
extend Create

# enum definitions for use by simple_enum gem
# Do not change the integer associated with a value
enum :rank, {
Form: 1,
Expand Down
21 changes: 5 additions & 16 deletions app/models/name_description.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,12 @@
class NameDescription < Description
require "acts_as_versioned"

# enum definitions for use by simple_enum gem
# Do not change the integer associated with a value
enum review_status:
{
unreviewed: 1,
unvetted: 2,
vetted: 3,
inaccurate: 4
}
enum source_type:
{
public: 1,
foreign: 2,
project: 3,
source: 4,
user: 5
}, _suffix: :source
enum :review_status, { unreviewed: 1, unvetted: 2, vetted: 3, inaccurate: 4 }

enum :source_type, { public: 1, foreign: 2, project: 3, source: 4, user: 5 },
suffix: :source, instance_methods: false

belongs_to :license
belongs_to :name
belongs_to :project
Expand Down
7 changes: 1 addition & 6 deletions app/models/project_member.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
# frozen_string_literal: true

class ProjectMember < ApplicationRecord
enum trust_level:
{
no_trust: 1,
hidden_gps: 2,
editing: 3
}
enum :trust_level, { no_trust: 1, hidden_gps: 2, editing: 3 }

belongs_to :project
belongs_to :user
Expand Down
74 changes: 19 additions & 55 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,62 +199,26 @@
class User < AbstractModel # rubocop:disable Metrics/ClassLength
require "digest/sha1"

# enum definitions for use by simple_enum gem
# Do not change the integer associated with a value
# first value is the default
enum thumbnail_size:
{
thumbnail: 1,
small: 2
},
_prefix: :thumb_size,
_default: "thumbnail"

enum image_size:
{
thumbnail: 1,
small: 2,
medium: 3,
large: 4,
huge: 5,
full_size: 6
},
_prefix: true,
_default: "medium"

enum votes_anonymous:
{
no: 1,
yes: 2,
old: 3
},
_prefix: :votes_anon,
_default: "no"

enum location_format:
{
postal: 1,
scientific: 2
},
_prefix: true,
_default: "postal"

enum hide_authors:
{
none: 1,
above_species: 2
},
_prefix: true,
_default: "none"

enum keep_filenames:
{
toss: 1,
keep_but_hide: 2,
keep_and_show: 3
},
_suffix: :filenames,
_default: "toss"
# First value is the default
enum :thumbnail_size, { thumbnail: 1, small: 2 },
prefix: :thumb_size, default: :thumbnail, instance_methods: false

enum :image_size,
{ thumbnail: 1, small: 2, medium: 3, large: 4, huge: 5, full_size: 6 },
prefix: true, default: :medium, instance_methods: false

enum :votes_anonymous, { no: 1, yes: 2, old: 3 },
prefix: :votes_anon, default: :no, instance_methods: false

enum :location_format, { postal: 1, scientific: 2 },
prefix: true, default: :postal, instance_methods: false

enum :hide_authors, { none: 1, above_species: 2 },
prefix: true, default: :none, instance_methods: false

enum :keep_filenames, { toss: 1, keep_but_hide: 2, keep_and_show: 3 },
suffix: :filenames, default: :toss, instance_methods: false

has_one :user_stats, dependent: :destroy

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ def test_index_where
login
get(:index, params: { where: location.name })
assert_displayed_title("Observations from #{location.name}")
assert_match(new_location_path(where: location.name), @response.body)
end

def test_index_where_page2
Expand Down

0 comments on commit 81dc3b0

Please sign in to comment.