source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/names/trackers/approve_controller.rb | Ruby | mit | 84 | main | 1,313 | # frozen_string_literal: true
# approve_name
module Names::Trackers
class ApproveController < ApplicationController
before_action :login_required
# Endpoint for admins to approve a tracker.
def new
return unless (tracker = find_or_goto_index(NameTracker, params[:id]))
approve_tracker_if_eve... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/descriptions/authors_controller.rb | Ruby | mit | 84 | main | 1,380 | # frozen_string_literal: true
module Descriptions
# manage (review: add or remove) authors of a Description
class AuthorsController < ApplicationController
# filters
before_action :login_required
def show
set_object_and_authors
if @authors.member?(@user) || @user.in_group?("reviewers")
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/descriptions/author_requests_controller.rb | Ruby | mit | 84 | main | 1,049 | # frozen_string_literal: true
module Descriptions
# request to be an Description author
class AuthorRequestsController < ApplicationController
# filters
before_action :login_required
# Form to compose email for the authors/reviewers.
# Linked from show_<object>.
def new
@object = Abstrac... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/herbaria/curator_requests_controller.rb | Ruby | mit | 84 | main | 2,009 | # frozen_string_literal: true
# Handles requests to be a herbarium curators
module Herbaria
class CuratorRequestsController < ApplicationController
# filters
before_action :login_required
before_action :keep_track_of_referrer
# Old MO Action (method) New "Normalized" Action (method)
# ---... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/herbaria/shared_private_methods.rb | Ruby | mit | 84 | main | 1,234 | # frozen_string_literal: true
# private methods shared by HerbariaController and subcontrollers
module Herbaria
module SharedPrivateMethods
private
# ---------- Filters -------------------------------------------------------
def keep_track_of_referrer
@back = params[:back] || request.referer
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/herbaria/search_controller.rb | Ruby | mit | 84 | main | 1,428 | # frozen_string_literal: true
# Herbaria search form and help.
#
# Route: `herbaria_search_path`, `new_herbaria_search_path`
# Only one action here. Call namespaced controller actions with a hash like
# `{ controller: "/herbaria/search", action: :create }`
module Herbaria
class SearchController < ApplicationControll... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/herbaria/curators_controller.rb | Ruby | mit | 84 | main | 1,743 | # frozen_string_literal: true
# Controls viewing and modifying herbaria.
module Herbaria
class CuratorsController < ApplicationController
# filters
before_action :login_required
before_action :keep_track_of_referrer, only: [:destroy]
# Old MO Action (method) New "Normalized" Action (method)
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/herbaria/merges_controller.rb | Ruby | mit | 84 | main | 1,392 | # frozen_string_literal: true
# Combine two herbaria
module Herbaria
class MergesController < ApplicationController
# filters
before_action :login_required
before_action :keep_track_of_referrer
# Old MO Action (method) New "Normalized" Action (method)
# ---------------------- -----... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/field_slips/qr_reader_controller.rb | Ruby | mit | 84 | main | 945 | # frozen_string_literal: true
module FieldSlips
class QRReaderController < ApplicationController
before_action :login_required
def new; end
def create
field_slip_params = permitted_qr_params
return unless check_for_qr_code(field_slip_params)
redirect_to("#{MO.http_domain}/qr/#{@qr_co... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/observations/external_links_controller.rb | Ruby | mit | 84 | main | 7,061 | # frozen_string_literal: true
# Add, edit and remove external links assoc. with obs.
module Observations
class ExternalLinksController < ApplicationController
before_action :login_required
def new
set_ivars_for_new
@external_link = ExternalLink.new(
user: @user,
observation: @obs... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/observations/identify_controller.rb | Ruby | mit | 84 | main | 2,429 | # frozen_string_literal: true
module Observations
class IdentifyController < ApplicationController
before_action :login_required
def index
build_index_with_query
end
def controller_model_name
"Observation"
end
private
# override the default? maybe no longer necessary
d... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/observations/downloads_controller.rb | Ruby | mit | 84 | main | 2,648 | # frozen_string_literal: true
module Observations
class DownloadsController < ApplicationController
before_action :login_required
def new
@query = find_or_create_query(:Observation, order_by: params[:by])
return too_many_results if too_many_results?
update_stored_query(@query) # also stor... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/observations/namings_controller.rb | Ruby | mit | 84 | main | 11,564 | # frozen_string_literal: true
# Controller for handling the naming of observations
module Observations
class NamingsController < ApplicationController # rubocop:disable Metrics/ClassLength
include ObservationsController::Validators
before_action :login_required
# Bullet wants us to eager load interest... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/observations/search_controller.rb | Ruby | mit | 84 | main | 3,572 | # frozen_string_literal: true
# Observations search form and help.
#
# Route: `observations_search_path`, `new_observations_search_path`
# Only one action here. Call namespaced controller actions with a hash like
# `{ controller: "/observations/search", action: :create }`
module Observations
class SearchController <... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/observations/locations_controller.rb | Ruby | mit | 84 | main | 4,649 | # frozen_string_literal: true
# list_merge_options
module Observations
class LocationsController < ApplicationController
before_action :login_required
before_action :store_location, only: :edit
############################################################################
#
# :section: Associate ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/observations/images_controller.rb | Ruby | mit | 84 | main | 7,221 | # frozen_string_literal: true
# Clicking on an image currently fires a GET to these actions... because it
# comes from a link made by Components::InteractiveImage(link: url_args)
# with CRUD refactor, change component link to fire a POST somehow?
module Observations
# Upload, attach, detach, edit Observation Images... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/observations/emails_controller.rb | Ruby | mit | 84 | main | 2,105 | # frozen_string_literal: true
# Send emails directly to the observation user via the application
module Observations
class EmailsController < ApplicationController
include ::Emailable
before_action :login_required
def new
@observation = find_or_goto_index(Observation, params[:id].to_s)
retu... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/observations/species_lists_controller.rb | Ruby | mit | 84 | main | 2,915 | # frozen_string_literal: true
# :manage_species_lists
# Linked from observation_tabs_helper, maybe should also link from spl :show?
# Table of links for dealing with a list of obs line by line, can add or remove
#
module Observations
# Add or remove one Observation from the Observation List
class SpeciesListsCon... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/observations/maps_controller.rb | Ruby | mit | 84 | main | 2,954 | # frozen_string_literal: true
module Observations
class MapsController < ApplicationController
include(ClusteredObservationMap)
before_action :login_required
def controller_model_name
"Observation"
end
# Map results of a search or index.
def index
show and return if params[:id]... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/observations/namings/votes_controller.rb | Ruby | mit | 84 | main | 5,069 | # frozen_string_literal: true
module Observations::Namings
class VotesController < ApplicationController
before_action :login_required # except: [:show]
# Index breakdown of votes for a given naming.
# Linked from: observations/show
# Displayed on show obs via popup for JS users.
# Has its own r... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/observations/namings/suggestions_controller.rb | Ruby | mit | 84 | main | 481 | # frozen_string_literal: true
# Generates suggested namings from ML
module Observations::Namings
class SuggestionsController < ApplicationController
before_action :login_required
def show
@observation = load_for_show_observation_or_goto_index(params[:id])
consensus = Observation::NamingConsen... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/observations/images/uploads_controller.rb | Ruby | mit | 84 | main | 2,863 | # frozen_string_literal: true
module Observations::Images
class UploadsController < ApplicationController
before_action :login_required
layout false
# Uploading images for an observation is a multi-stage thing.
# First, each selected image with its EXIF data is read and displayed in
# the creat... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/species_lists/uploads_controller.rb | Ruby | mit | 84 | main | 1,233 | # frozen_string_literal: true
module SpeciesLists
class UploadsController < ApplicationController
before_action :login_required
# Form to let user add to a species_list from file.
def new
return unless (@species_list = find_species_list!)
if permission!(@species_list)
query = create... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/species_lists/search_controller.rb | Ruby | mit | 84 | main | 1,834 | # frozen_string_literal: true
# SpeciesLists search form and help.
#
# Route: `species_lists_search_path`, `new_species_lists_search_path`
# Only one action here. Call namespaced controller actions with a hash like
# `{ controller: "/species_lists/search", action: :create }`
module SpeciesLists
class SearchControlle... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/species_lists/downloads_controller.rb | Ruby | mit | 84 | main | 2,007 | # frozen_string_literal: true
module SpeciesLists
class DownloadsController < ApplicationController
before_action :login_required
############################################################################
#
# :section: Reports
#
############################################################... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/species_lists/write_in_controller.rb | Ruby | mit | 84 | main | 6,321 | # frozen_string_literal: true
module SpeciesLists
class WriteInController < ApplicationController
before_action :login_required
def new
@species_list = SpeciesList.find(params[:id])
init_member_vars_for_create
end
def create
@species_list = SpeciesList.find(params[:id])
if p... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/species_lists/shared_private_methods.rb | Ruby | mit | 84 | main | 4,042 | # frozen_string_literal: true
# private methods shared by SpeciesListsController and subcontrollers
module SpeciesLists
module SharedPrivateMethods
############################################################################
#
# :section: Helpers
#
###############################################... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/species_lists/name_lists_controller.rb | Ruby | mit | 84 | main | 2,058 | # frozen_string_literal: true
module SpeciesLists
class NameListsController < ApplicationController
before_action :login_required
before_action :require_successful_user
# Specialized javascripty form for creating a list of names, at Darvin's
# request. Links into create_species_list.
# Uses same... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/species_lists/projects_controller.rb | Ruby | mit | 84 | main | 5,568 | # frozen_string_literal: true
module SpeciesLists
class ProjectsController < ApplicationController
before_action :login_required
# ----------------------------
# :section: Manage Projects
# ----------------------------
def edit
return unless (@list = find_species_list!)
if permiss... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/species_lists/observations_controller.rb | Ruby | mit | 84 | main | 3,202 | # frozen_string_literal: true
#
# :add_remove_observations
# Linked from observations :index and species_lists :show
# Form that sends all obs from current query to be added or removed from an spl
module SpeciesLists
class ObservationsController < ApplicationController
before_action :login_required
# :ad... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/species_lists/shared_render_methods.rb | Ruby | mit | 84 | main | 1,815 | # frozen_string_literal: true
# private methods shared by DonwloadsController and NameListsController
module SpeciesLists
module SharedRenderMethods
def render_name_list_as_txt(names)
charset = "UTF-8"
str = "\xEF\xBB\xBF#{names.map(&:real_search_name).join("\r\n")}"
send_data(str, type: "text/... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/admin/banners_controller.rb | Ruby | mit | 84 | main | 611 | # frozen_string_literal: true
class Admin::BannersController < AdminController
def index
@banner = Banner.current || Banner.new
end
def create
@banner = Banner.new(banner_params)
if @banner.save
flash_notice(:banner_update_success.t)
redirect_to(admin_banners_path)
else
flash_... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/admin/donations_controller.rb | Ruby | mit | 84 | main | 1,595 | # frozen_string_literal: true
module Admin
# Allow users to make monetary donations via the website
class DonationsController < AdminController
def new
@donation = Donation.new
end
def create
@donation = create_donation(params)
end
# Review donations
def edit
@donations ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/admin/blocked_ips_controller.rb | Ruby | mit | 84 | main | 3,943 | # frozen_string_literal: true
module Admin
class BlockedIpsController < AdminController
IPS_PER_PAGE = 50
# This page allows editing of blocked ips via params
# params[:add_okay] and params[:add_bad]
# Using params[:report] will show info about a chosen IP
def edit
@ip = params[:report] if... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/admin/session_controller.rb | Ruby | mit | 84 | main | 3,443 | # frozen_string_literal: true
# =============== Controls access to admin mode ================
#
# NOTE:
# Unlike controllers inheriting from AdminController, this controller's
# actions do not require current user to be an admin already in admin mode,
# i.e. a user where @user.admin && in_admin_mode
#
# Th... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/admin/users_controller.rb | Ruby | mit | 84 | main | 1,823 | # frozen_string_literal: true
module Admin
class UsersController < AdminController
### Edit user bonuses
def edit
return unless (@user2 = find_or_goto_index(User, params[:id].to_s))
@user_stats = UserStats.find_by(user_id: @user2.id) ||
UserStats.create(user_id: @user2.id)
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/admin/emails/webmaster_questions_controller.rb | Ruby | mit | 84 | main | 2,459 | # frozen_string_literal: true
module Admin
module Emails
# NOTE: Does not inherit from AdminController
class WebmasterQuestionsController < ApplicationController
def new
@email = params.dig(:user, :email)
@message = params.dig(:question, :message)
@email = @user.email if @user
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/admin/emails/name_change_requests_controller.rb | Ruby | mit | 84 | main | 2,916 | # frozen_string_literal: true
module Admin
module Emails
class NameChangeRequestsController < ApplicationController
include ::Emailable
before_action :login_required
def new
unless check_both_names!
redirect_back_or_default("/")
return
end
unless c... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/admin/emails/merge_requests_controller.rb | Ruby | mit | 84 | main | 2,857 | # frozen_string_literal: true
module Admin
module Emails
class MergeRequestsController < ApplicationController
include ::Emailable
before_action :login_required
def new
return unless (@model = validate_merge_model!(params[:type]))
unless validate_objects!
redirect_b... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/field_slips_controller/observation_handling.rb | Ruby | mit | 84 | main | 7,376 | # frozen_string_literal: true
# Private helpers for creating, updating, and linking observations
# when working with field slips.
module FieldSlipsController::ObservationHandling
private
def quick_create_observation
fs_params = params[:field_slip]
# Must have valid name and location
location = Locatio... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/field_slips_controller/show.rb | Ruby | mit | 84 | main | 841 | # frozen_string_literal: true
# see field_slips_controller.rb
module FieldSlipsController::Show
# GET /field_slips/1 or /field_slips/1.json or /qr/XYZ-123
def show
if params[:id].match?(/^\d+$/)
set_field_slip
else
handle_by_code
end
params[:code] = params[:id].upcase
redirect_to(ne... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/field_slips_controller/index.rb | Ruby | mit | 84 | main | 1,225 | # frozen_string_literal: true
# see field_slips_controller.rb
module FieldSlipsController::Index
def index
build_index_with_query
end
private
def default_sort_order
::Query::FieldSlips.default_order # :date
end
def index_active_params
[:project, :by_user, :by, :q, :id].freeze
end
# Disp... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/images/filenames_controller.rb | Ruby | mit | 84 | main | 464 | # frozen_string_literal: true
# Images::FilenamesController
module Images
class FilenamesController < ApplicationController
before_action :login_required
# NO VIEW TEMPLATE
# Linked from account/preferences/_privacy
# bulk_filename_purge
def update
Image.where(user_id: @user.id).update_all... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/images/votes_controller.rb | Ruby | mit | 84 | main | 923 | # frozen_string_literal: true
module Images
class VotesController < ApplicationController
before_action :login_required
def update
@id = params[:image_id]
@image = find_or_goto_index(Image, @id)
return unless @image
value = params[:value]
raise("Bad value.") if value != "0" &&... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/images/emails_controller.rb | Ruby | mit | 84 | main | 2,180 | # frozen_string_literal: true
# Send emails directly to the observation user via the application
module Images
class EmailsController < ApplicationController
include ::Emailable
before_action :login_required
def new
return unless
(@image = find_or_goto_index(Image, params[:id].to_s)) &&
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/images/exports_controller.rb | Ruby | mit | 84 | main | 1,102 | # frozen_string_literal: true
# This is a simple Turbo callback to toggle the export button on an image,
# but it appears to be currently unused.
# TODO: Harmonize this with the "ExportController", for exports and ml status.
# If that controller should update any page UIs without a reload, it should
# probably be brok... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/images/originals_controller.rb | Ruby | mit | 84 | main | 2,238 | # frozen_string_literal: true
# Images::OriginalsController
module Images
class OriginalsController < ApplicationController
# This is an AJAX request so we can keep overhead low.
disable_filters
def show
# Because this is only called from stimulus within valid pages, we
# can assume the imag... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/images/licenses_controller.rb | Ruby | mit | 84 | main | 918 | # frozen_string_literal: true
# Images::LicensesController
module Images
class LicensesController < ApplicationController
before_action :login_required
# Linked from show_obs, account prefs tabs and section, acct profile
# Tabular form that lets user change licenses of their images. The table
# gro... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/images/exif_controller.rb | Ruby | mit | 84 | main | 806 | # frozen_string_literal: true
# Images::EXIFController
module Images
class EXIFController < ApplicationController
before_action :login_required
# Linked from lightbox and show_image
# Returns EXIF header of image as HTML table.
def show
@image = Image.find(params[:id])
@data, @status, @r... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/images/transformations_controller.rb | Ruby | mit | 84 | main | 824 | # frozen_string_literal: true
module Images
class TransformationsController < ApplicationController
before_action :login_required
# Used by show_image to rotate and flip image. was GET. Currently a PUT
def update
image = find_or_goto_index(Image, params[:id].to_s)
return unless image
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/images/votes/anonymity_controller.rb | Ruby | mit | 84 | main | 1,352 | # frozen_string_literal: true
# NOTE: These two are more properly account preferences actions
# Move to Images::Votes::AnonymityController#edit and update
# Move test from images_controller_test
#
module Images::Votes
class AnonymityController < ApplicationController
before_action :login_required
# Bulk upd... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/application_controller/indexes.rb | Ruby | mit | 84 | main | 19,830 | # frozen_string_literal: true
# ==== Indexes
# show_index_of_objects:: Show paginated set of Query results as a list.
# add_sorting_links:: Create sorting links for index pages.
# find_or_goto_index:: Look up object by id, displaying error and
# redirecting on failure.
# goto_i... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/application_controller/queries.rb | Ruby | mit | 84 | main | 16,380 | # frozen_string_literal: true
# ==== Queries
# create_query:: Create a new Query from scratch.
# find_or_create_query:: Find appropriate Query or create as necessary.
# find_query:: Find a given Query or return nil.
#
# update_stored_query:: Saves a passed query and stores id in the ses... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/application_controller/authentication.rb | Ruby | mit | 84 | main | 7,847 | # frozen_string_literal: true
# ==== User authentication
# autologin:: (filter: determine which user is logged in)
# login_for_ajax:: (filter: minimal version of autologin for ajax)
# permission?:: Make sure current User is the right one.
# permission!:: Same, but flashe... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/application_controller/name_validation.rb | Ruby | mit | 84 | main | 3,594 | # frozen_string_literal: true
# ==== Name validation
# construct_approved_names:: Creates a list of names if they've been approved.
# construct_approved_name:: (helper)
#
module ApplicationController::NameValidation
##############################################################################
#
# :section:... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/application_controller/internationalization.rb | Ruby | mit | 84 | main | 5,478 | # frozen_string_literal: true
# ==== Internationalization
# all_locales:: Array of available locales for which we have
# translations.
# set_locale:: (filter: determine which locale is requested)
# set_timezone:: (filter: Set timezone from cookie set by cl... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/application_controller/flash_notices.rb | Ruby | mit | 84 | main | 5,135 | # frozen_string_literal: true
# ==== Flash notices
# flash_notices?:: Are there any errors pending?
# flash_get_notices:: Get list of errors.
# flash_notice_level:: Get current notice level.
# flash_clear:: Clear error messages.
# flash_notice:: Add a success message.
# fla... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/test_pages/flash_redirection_controller.rb | Ruby | mit | 84 | main | 763 | # frozen_string_literal: true
module TestPages
class FlashRedirectionController < ApplicationController
before_action :login_required
# NOTE: this action does not require admin access.
def show
tags = params[:tags].to_s.split(",")
if tags.any?
flash_notice(tags.pop.to_sym.t)
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/visual_groups/images_controller.rb | Ruby | mit | 84 | main | 1,278 | # frozen_string_literal: true
module VisualGroups
class ImagesController < ApplicationController
before_action :login_required
def update
image_id = params[:id]
status = params[:status]
status = "" unless Image.find_by(id: image_id)
visual_group = VisualGroup.find_by(id: params[:visu... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/occurrences_controller/resolve_projects.rb | Ruby | mit | 84 | main | 874 | # frozen_string_literal: true
# Handles POST from the project membership confirmation modal.
# GET renders the edit page with the modal overlaid.
module OccurrencesController::ResolveProjects
def resolve_projects
return unless find_occurrence!
@gaps = @occurrence.project_membership_gaps
if @gaps.empty?
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/occurrences_controller/edit.rb | Ruby | mit | 84 | main | 5,489 | # frozen_string_literal: true
# Edit and Update actions for OccurrencesController.
module OccurrencesController::Edit
def edit
return unless find_occurrence!
render_edit_page
end
def update
return unless find_occurrence!
process_update
end
private
def process_update
primary_obs = @... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/occurrences_controller/show.rb | Ruby | mit | 84 | main | 1,537 | # frozen_string_literal: true
# Show and Destroy actions for OccurrencesController.
module OccurrencesController::Show
def show
return unless find_occurrence!
render_show_page
end
def destroy
return unless find_occurrence!
obs_id = @occurrence.primary_observation&.id
destroy_occurrence!
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/observations_controller/create.rb | Ruby | mit | 84 | main | 9,480 | # frozen_string_literal: true
module ObservationsController::Create
include ObservationsController::SharedFormMethods
include ObservationsController::Validators
include ::Locationable
# Form to create a new observation, naming, vote, and images.
# Linked from: left panel
#
# Inputs:
# params[:observ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/observations_controller/index.rb | Ruby | mit | 84 | main | 6,774 | # frozen_string_literal: true
# see observations_controller.rb
class ObservationsController
module Index
def index
make_name_suggestions
set_project_ivar
build_index_with_query
end
private
# Default on home is :rss_log (:log_updated_at), not :date.
# Maybe other filters should... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/observations_controller/show.rb | Ruby | mit | 84 | main | 4,102 | # frozen_string_literal: true
# see observations_controller.rb
module ObservationsController::Show
# Display observation and related namings, comments, votes, images, etc.
# This should be a redirection, not rendered, due to large number of
# @variables that need to be set up for the view. Lots of views are use... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/observations_controller/edit_and_update.rb | Ruby | mit | 84 | main | 8,040 | # frozen_string_literal: true
# see observations_controller.rb
module ObservationsController::EditAndUpdate
include ObservationsController::SharedFormMethods
include ObservationsController::Validators
include ::Locationable
# Form to edit an existing observation.
# Linked from: left panel
#
#
#
# In... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/observations_controller/new.rb | Ruby | mit | 84 | main | 4,533 | # frozen_string_literal: true
module ObservationsController::New
include ObservationsController::SharedFormMethods
include ObservationsController::Validators
# Form to create a new observation, naming, vote, and images.
# Linked from: left panel
#
# Inputs:
# params[:observation][...] ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/observations_controller/destroy.rb | Ruby | mit | 84 | main | 1,383 | # frozen_string_literal: true
# see observations_controller.rb
module ObservationsController::Destroy
# Callback to destroy an observation (and associated namings, votes, etc.)
# Linked from: observations/show (note that links require jquery_ujs)
# Inputs: params[:id] (observation)
# Redirects to next obs in q... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/observations_controller/shared_form_methods.rb | Ruby | mit | 84 | main | 10,081 | # frozen_string_literal: true
# :section: Shared form private methods
#
# permitted_observation_args
# update_permitted_observation_attributes
# permitted_observation_params
# notes_to_sym_and_compact
# notes_param_present?
#
# init_license_var
# init_new_image_var
# init_specimen_vars
# in... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/observations_controller/validators.rb | Ruby | mit | 84 | main | 5,499 | # frozen_string_literal: true
# :section: Validators
# These validators return Boolean values, and also set the @any_errors ivar.
#
# validate_name
# name_params
# resolve_name(...)
#
# validate_place_name
#
# validate_projects
# checked_project_conflicts
# Included in both ObservationsContr... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/locations/reverse_name_order_controller.rb | Ruby | mit | 84 | main | 423 | # frozen_string_literal: true
# reverse_name_order
module Locations
class ReverseNameOrderController < ApplicationController
before_action :login_required
# Callback for :show
def update
if (loc = Location.safe_find(params[:id].to_s))
loc.name, loc.scientific_name = loc.scientific_name, lo... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/locations/descriptions_controller.rb | Ruby | mit | 84 | main | 5,678 | # frozen_string_literal: true
module Locations
class DescriptionsController < ApplicationController
include ::Descriptions
include ::Locations::Descriptions::SharedPrivateMethods
before_action :store_location, except: [:index, :destroy]
before_action :login_required
before_action :require_succes... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/locations/versions_controller.rb | Ruby | mit | 84 | main | 826 | # frozen_string_literal: true
# show_past_location
module Locations
class VersionsController < ApplicationController
before_action :login_required
before_action :store_location, only: [:show]
# Show past version of Location. Accessible only from show_location page.
def show
return unless find... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/locations/maps_controller.rb | Ruby | mit | 84 | main | 706 | # frozen_string_literal: true
# map_locations
module Locations
class MapsController < ApplicationController
before_action :login_required
def controller_model_name
"Location"
end
# Map results of a search or index of Locations.
def show
@query = find_or_create_query(:Location)
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/locations/countries_controller.rb | Ruby | mit | 84 | main | 269 | # frozen_string_literal: true
# list_countries
module Locations
class CountriesController < ApplicationController
before_action :login_required
# Displays a list of all countries with counts.
def index
@cc = ::CountryCounter.new
end
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/locations/search_controller.rb | Ruby | mit | 84 | main | 1,571 | # frozen_string_literal: true
# Locations search form and help.
#
# Route: `locations_search_path`, `new_locations_search_path`
# Only one action here. Call namespaced controller actions with a hash like
# `{ controller: "/locations/search", action: :create }`
module Locations
class SearchController < ApplicationCon... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/locations/descriptions/versions_controller.rb | Ruby | mit | 84 | main | 586 | # frozen_string_literal: true
# show_past_location_description
module Locations::Descriptions
class VersionsController < ApplicationController
include ::Locations::Descriptions::SharedPrivateMethods
before_action :login_required
before_action :store_location
# Show past version of LocationDescripti... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/locations/descriptions/moves_controller.rb | Ruby | mit | 84 | main | 319 | # frozen_string_literal: true
# move_descriptions:: Move a description to another parent.
module Locations::Descriptions
class MovesController < ApplicationController
before_action :login_required
include ::Descriptions::Moves
include ::Locations::Descriptions::SharedPrivateMethods
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/locations/descriptions/merges_controller.rb | Ruby | mit | 84 | main | 318 | # frozen_string_literal: true
# merge_descriptions:: Merge a description with another.
module Locations::Descriptions
class MergesController < ApplicationController
before_action :login_required
include ::Descriptions::Merges
include ::Locations::Descriptions::SharedPrivateMethods
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/locations/descriptions/defaults_controller.rb | Ruby | mit | 84 | main | 324 | # frozen_string_literal: true
# make_description_default:: Make a description the default one.
module Locations::Descriptions
class DefaultsController < ApplicationController
before_action :login_required
include ::Descriptions::Defaults
include ::Locations::Descriptions::SharedPrivateMethods
end
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/locations/descriptions/shared_private_methods.rb | Ruby | mit | 84 | main | 426 | # frozen_string_literal: true
module Locations::Descriptions
module SharedPrivateMethods
private
# This either finds a description by id, or sets the ivar from the param.
def find_description!(id = nil)
desc_id = id || params[:id]
@description = LocationDescription.show_includes.safe_find(de... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/projects/members_controller.rb | Ruby | mit | 84 | main | 10,018 | # frozen_string_literal: true
# ==== Manage Project Members
# new::
# create:: (add member)
# edit::
# update:: (change_member_status)
module Projects
# CRUD for project members
class MembersController < ApplicationController
before_action :login_required
def index
return unless find_project!
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/projects/violations_controller.rb | Ruby | mit | 84 | main | 1,496 | # frozen_string_literal: true
# Show and remove non-compliant Observations from a Project
module Projects
# Actions
# -------
# index (get)
# edit (get)
# update (patch)
#
class ViolationsController < ApplicationController
before_action :login_required
# Cannot figure out the eager loading here.
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/projects/admin_requests_controller.rb | Ruby | mit | 84 | main | 1,469 | # frozen_string_literal: true
# Manage requests to be a project admin
module Projects
class AdminRequestsController < ApplicationController
before_action :login_required
# Form to compose email for the admins
# Linked from: show_project
# Inputs:
# params[:project_id] (was :id)
# Outputs:
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/projects/target_names_controller.rb | Ruby | mit | 84 | main | 2,884 | # frozen_string_literal: true
module Projects
class TargetNamesController < ApplicationController
before_action :login_required
before_action :set_project
before_action :require_admin
def create
names = parse_names_from_params
if names.any?
add_names(names)
else
fla... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/projects/search_controller.rb | Ruby | mit | 84 | main | 2,089 | # frozen_string_literal: true
# Projects search form and help.
#
# Route: `projects_search_path`, `new_projects_search_path`
# Only one action here. Call namespaced controller actions with a hash like
# `{ controller: "/projects/search", action: :create }`
module Projects
class SearchController < ApplicationControll... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/projects/updates_controller.rb | Ruby | mit | 84 | main | 3,977 | # frozen_string_literal: true
module Projects
class UpdatesController < ApplicationController
before_action :login_required
before_action :set_project
before_action :require_admin
def index
results = build_index_results
render(Views::Controllers::Projects::Updates::Index.new(
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/projects/locations_controller.rb | Ruby | mit | 84 | main | 507 | # frozen_string_literal: true
module Projects
class LocationsController < ApplicationController
include Projects::LocationGrouping
before_action :login_required
def index
return unless find_project!
@grouped_data, @ungrouped_locations =
build_grouped_locations(@project)
@obs_... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/projects/aliases_controller.rb | Ruby | mit | 84 | main | 6,089 | # frozen_string_literal: true
module Projects
class AliasesController < ApplicationController
before_action :login_required
before_action :set_project_alias, only: [:show, :edit, :update, :destroy]
def index
@project = Project.find(params[:project_id])
@project_aliases = ProjectAlias.where(p... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/projects/target_locations_controller.rb | Ruby | mit | 84 | main | 2,560 | # frozen_string_literal: true
module Projects
class TargetLocationsController < ApplicationController
include Projects::LocationGrouping
before_action :login_required
before_action :set_project
before_action :require_admin
def create
locations = parse_locations_from_params
if locati... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/projects/field_slips_controller.rb | Ruby | mit | 84 | main | 2,934 | # frozen_string_literal: true
# ==== Manage Project Field Slips
# new:: Allow new job to be created
# create:: Create field slip print job
module Projects
class FieldSlipsController < ApplicationController
before_action :login_required
def new
return unless find_project!
@field_slip_max = f... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/controllers/projects_controller/validators.rb | Ruby | mit | 84 | main | 781 | # frozen_string_literal: true
module ProjectsController::Validators
private
def valid_title
@title = params[:project][:title].to_s
if @title.blank?
flash_error(:add_project_need_title.t)
false
elsif (project2 = Project.find_by_title(@title)) &&
(project2 != @project)
flash_... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/mailers/comment_mailer.rb | Ruby | mit | 84 | main | 513 | # frozen_string_literal: true
# Notify user of comment on their object.
class CommentMailer < ApplicationMailer
after_action :news_delivery, only: [:build]
def build(sender:, receiver:, target:, comment:)
setup_user(receiver)
@title = :email_subject_comment.l(name: target.unique_text_name)
@sender = s... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/mailers/verify_api_key_mailer.rb | Ruby | mit | 84 | main | 553 | # frozen_string_literal: true
# Email sent to verify and activate a new API key.
class VerifyAPIKeyMailer < ApplicationMailer
after_action :webmaster_delivery, only: [:build]
def build(receiver:, app_user:, api_key:)
setup_user(receiver)
@title = :email_subject_verify_api_key.l
@app_user = app_user
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/mailers/observer_question_mailer.rb | Ruby | mit | 84 | main | 550 | # frozen_string_literal: true
# User asking user about an observation.
class ObserverQuestionMailer < ApplicationMailer
after_action :news_delivery, only: [:build]
def build(sender:, observation:, message:)
setup_user(observation.user)
name = observation.unique_text_name
@title = :email_subject_observ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/mailers/password_mailer.rb | Ruby | mit | 84 | main | 399 | # frozen_string_literal: true
# User forgot their password.
class PasswordMailer < ApplicationMailer
after_action :webmaster_delivery, only: [:build]
def build(receiver:, password:)
setup_user(receiver)
@title = :email_subject_new_password.l
@password = password
debug_log(:new_password, nil, @user... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/mailers/occurrence_change_mailer.rb | Ruby | mit | 84 | main | 560 | # frozen_string_literal: true
# Notify observation owner when their observation is added to or
# removed from an occurrence.
class OccurrenceChangeMailer < ApplicationMailer
def build(sender:, receiver:, observation:, action:)
setup_user(receiver)
name = observation.user_unique_format_name(receiver)
@tit... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/mailers/verify_account_mailer.rb | Ruby | mit | 84 | main | 396 | # frozen_string_literal: true
# Email sent to verify user's email.
class VerifyAccountMailer < ApplicationMailer
after_action :webmaster_delivery, only: [:build]
def build(receiver:)
setup_user(receiver)
@title = :email_subject_verify.l
debug_log(:user_question, nil, receiver, email: receiver.email)
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/mailers/observation_change_mailer.rb | Ruby | mit | 84 | main | 871 | # frozen_string_literal: true
# Notify user of change in observation.
class ObservationChangeMailer < ApplicationMailer
after_action :news_delivery, only: [:build]
def build(sender:, receiver:, observation:, note:, time:)
setup_user(receiver)
@title = observation_change_title(observation, note, receiver)
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/mailers/add_herbarium_record_mailer.rb | Ruby | mit | 84 | main | 604 | # frozen_string_literal: true
# Let curators know about a herbarium_record added by a non-curator.
class AddHerbariumRecordMailer < ApplicationMailer
after_action :news_delivery, only: [:build]
def build(sender:, receiver:, herbarium_record:)
setup_user(receiver)
@title = :email_subject_add_herbarium_reco... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.