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/mailers/approval_mailer.rb | Ruby | mit | 84 | main | 409 | # frozen_string_literal: true
# Admins sending approval of a user's request.
class ApprovalMailer < ApplicationMailer
after_action :news_delivery, only: [:build]
def build(receiver:, subject:, message:)
setup_user(receiver)
@title = subject
@message = message
debug_log(:approval, ::User.admin, rec... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/mailers/project_admin_request_mailer.rb | Ruby | mit | 84 | main | 485 | # frozen_string_literal: true
# Ask project admins for admin privileges on project.
class ProjectAdminRequestMailer < ApplicationMailer
after_action :news_delivery, only: [:build]
def build(sender:, receiver:, project:, subject:, message:)
setup_user(receiver)
@title = subject
@sender = sender
@me... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/mailers/author_mailer.rb | Ruby | mit | 84 | main | 502 | # frozen_string_literal: true
# Ask reviewers for authorship credit.
class AuthorMailer < ApplicationMailer
after_action :news_delivery, only: [:build]
def build(sender:, receiver:, object:, subject:, message:)
setup_user(receiver)
@title = subject
@sender = sender
@message = message || ""
@ob... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/mailers/consensus_change_mailer.rb | Ruby | mit | 84 | main | 873 | # frozen_string_literal: true
# Notify user of name change of their obs.
class ConsensusChangeMailer < ApplicationMailer
after_action :news_delivery, only: [:build]
def build(sender:, receiver:, observation:, old_name:, new_name:)
setup_user(receiver)
@observation = observation
@old_name = old_name
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/mailers/webmaster_mailer.rb | Ruby | mit | 84 | main | 544 | # frozen_string_literal: true
# User asking webmaster a question.
class WebmasterMailer < ApplicationMailer
after_action :webmaster_delivery, only: [:build]
def build(sender_email:, message:, subject: nil)
I18n.locale = MO.default_locale
@title = subject || :email_subject_webmaster_question.l(user: sender... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/mailers/naming_tracker_mailer.rb | Ruby | mit | 84 | main | 625 | # frozen_string_literal: true
# Notify user someone has observed a name they are interested in.
class NamingTrackerMailer < ApplicationMailer
after_action :news_delivery, only: [:build]
def build(receiver:, naming:)
setup_user(receiver)
search_name = naming.name.user_real_search_name(@user)
name = "#{... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/mailers/name_proposal_mailer.rb | Ruby | mit | 84 | main | 537 | # frozen_string_literal: true
# Notify user of name proposal for their obs.
class NameProposalMailer < ApplicationMailer
after_action :news_delivery, only: [:build]
def build(sender:, receiver:, naming:, observation:)
setup_user(receiver)
@title = :email_subject_name_proposal.l(
name: naming.user_te... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/mailers/name_change_mailer.rb | Ruby | mit | 84 | main | 1,220 | # frozen_string_literal: true
# Notify user of change in name description.
class NameChangeMailer < ApplicationMailer
after_action :news_delivery, only: [:build]
# Refactored to accept serializable arguments for deliver_later compatibility.
# ObjectChange instances are constructed here from the IDs and versions... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/mailers/location_change_mailer.rb | Ruby | mit | 84 | main | 1,011 | # frozen_string_literal: true
# Notify user of change in location description.
class LocationChangeMailer < ApplicationMailer
after_action :news_delivery, only: [:build]
# Refactored to accept serializable arguments for deliver_later compatibility.
# ObjectChange instances are constructed here from the IDs and ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/mailers/commercial_inquiry_mailer.rb | Ruby | mit | 84 | main | 557 | # frozen_string_literal: true
# User asking user about an image.
class CommercialInquiryMailer < ApplicationMailer
after_action :news_delivery, only: [:build]
# Note the recipient comes from the Image object, image.user
def build(sender:, image:, message:)
setup_user(image.user)
@sender = sender
@ti... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/mailers/user_question_mailer.rb | Ruby | mit | 84 | main | 421 | # frozen_string_literal: true
# User asking user about anything else.
class UserQuestionMailer < ApplicationMailer
after_action :news_delivery, only: [:build]
def build(sender:, receiver:, subject:, message:)
setup_user(receiver)
@title = subject
@sender = sender
@message = message || ""
debug... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/mailers/naming_observer_mailer.rb | Ruby | mit | 84 | main | 576 | # frozen_string_literal: true
# Tell observer someone is interested in their obs.
class NamingObserverMailer < ApplicationMailer
after_action :news_delivery, only: [:build]
def build(receiver:, naming:, name_tracker:)
return unless name_tracker.approved
sender = name_tracker.user
setup_user(receiver)... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/mailers/application_mailer.rb | Ruby | mit | 84 | main | 2,814 | # frozen_string_literal: true
# Base class for mailers for each type of email
class ApplicationMailer < ActionMailer::Base
# Allow folder organization in the app/views folder
append_view_path Rails.root.join("app/views/mailers")
# Use native Ruby URI::MailTo class
def self.valid_email_address?(address)
a... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/presenters/base_presenter.rb | Ruby | mit | 84 | main | 588 | # frozen_string_literal: true
# https://nithinbekal.com/posts/rails-presenters/
# By inheriting from Ruby’s builtin SimpleDelegator class and calling super
# in the initialize method, we make sure that if we call any method that is
# not defined in the presenter, it passes it on to the model object.
class BasePresente... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/project_alias.rb | Ruby | mit | 84 | main | 957 | # frozen_string_literal: true
class ProjectAlias < AbstractModel
# Project admins can define a set of "aliases" for users and
# locations to facilitate data entry in the field. E.g., "NJW" can
# be made to represent the user `nathan`, or "Walk 10" for the
# location`USA, Massachusetts, Wellfleet, Marconi Beach... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/location_description_admin.rb | Ruby | mit | 84 | main | 206 | # frozen_string_literal: true
# Glue table between location_descriptions and user_groups.
class LocationDescriptionAdmin < ApplicationRecord
belongs_to :location_description
belongs_to :user_group
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/naming.rb | Ruby | mit | 84 | main | 13,408 | # frozen_string_literal: true
#
# = Naming Model
#
# Naming's are used to associate a proposed Name with an Observation. An
# Observation generally has one or more Naming's, but it can also have none,
# meaning that it is unidentified.
#
# == Attributes
#
# id:: Locally unique numerical id, ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/license.rb | Ruby | mit | 84 | main | 4,695 | # frozen_string_literal: true
#
# = License Model
#
# Very simple model to hold info about a copyright license. Originally
# intended for use by Image, but now extended to Name Descriptions.
#
# == Deprecation
#
# Instead of deleting out-dated License's, since that would involve finding
# and updating thousands... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/name_description.rb | Ruby | mit | 84 | main | 11,111 | # frozen_string_literal: true
#
# = Name Descriptions
#
# == Version
#
# Changes are kept in the "name_description_versions" table using
# ActiveRecord::Acts::Versioned.
#
# == Attributes
#
# id:: (-) Locally unique numerical id, starting at 1.
# created_at:: (-) Date/time it was first creat... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/image.rb | Ruby | mit | 84 | main | 40,646 | # frozen_string_literal: true
# = Image Model
#
# Most images are, of course, mushrooms, but mugshots use this class, as well.
# They are indistinguishable at the moment.
#
# == Votes
#
# Voting is kept very simple for now. More might be done later using RDF.
# User's can choose one of four levels. Their vote ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/inat_import_job_tracker.rb | Ruby | mit | 84 | main | 1,409 | # frozen_string_literal: true
# For display of status of an InatImportJob
#
# == Attributes
# inat_import:: id of the iNatImport for the job
#
# == Methods
# status:: state of the iNat import of this tracker
# elapsed_time:: time since the tracker was created
# help:: help message displayed at t... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/name.rb | Ruby | mit | 84 | main | 19,610 | # frozen_string_literal: true
#
# = Name Model
#
# This model describes a single scientific name. The related class Synonym,
# which can own multiple Name's, more accurately embodies the abstract concept
# of a species. A Name, on the other hand, refers to a single epithet, in a
# single sense -- that is, a uni... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/abstract_model.rb | Ruby | mit | 84 | main | 24,707 | # frozen_string_literal: true
#
# = Extensions to ApplicationRecord
#
# == Methods
#
# type_tag:: Language tag, e.g., :observation, :rss_log, etc.
#
# ==== Extensions to "find"
# safe_find:: Same as <tt>find(id)</tt> but return nil if not found.
# find_object:: Look up an object by clas... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/field_slip_job_tracker.rb | Ruby | mit | 84 | main | 1,341 | # frozen_string_literal: true
class FieldSlipJobTracker < AbstractModel
PUBLIC_DIR = "public/"
SUBDIR = "shared"
PDF_DIR = PUBLIC_DIR + SUBDIR
enum :status, { Starting: 1, Processing: 2, Done: 3 }
belongs_to :user
# Returns the PDF directory to use. Can be overridden in subclasses or tests.
def self.p... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/comment.rb | Ruby | mit | 84 | main | 10,217 | # frozen_string_literal: true
#
# = Comment Model
#
# A comment is a bit of text a User attaches to an object such as an
# Observation. It is polymorphic in the sense that Comment's can be attached
# to any kind of object, including:
#
# * Location
# * Name
# * Observation
# * Project
# * SpeciesList
#
# ==... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/location_description_reader.rb | Ruby | mit | 84 | main | 207 | # frozen_string_literal: true
# Glue table between location_descriptions and user_groups.
class LocationDescriptionReader < ApplicationRecord
belongs_to :location_description
belongs_to :user_group
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/location_description.rb | Ruby | mit | 84 | main | 6,611 | # frozen_string_literal: true
#
# = Location Descriptions
#
# == Version
#
# Changes are kept in the "location_description_versions" table using
# ActiveRecord::Acts::Versioned.
#
# == Attributes
#
# id:: (-) Locally unique numerical id, starting at 1.
# created_at:: (-) Date/time it was fir... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/visual_group.rb | Ruby | mit | 84 | main | 1,863 | # frozen_string_literal: true
class VisualGroup < AbstractModel
has_many :visual_group_images, dependent: :destroy
has_many :images, through: :visual_group_images
belongs_to :visual_model
validates :name, presence: {
message: proc { :cannot_be_blank.t }
}
validates :name, format: {
without: /\t/, ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/herbarium.rb | Ruby | mit | 84 | main | 8,050 | # frozen_string_literal: true
#
# = Herbarium Model
#
# Represents an herbarium, either an official institution like NYBG or a more
# informal entity such as a user's personal herbarium.
#
# == Attributes
#
# id:: Locally unique numerical id, starting at 1.
# created_at:: Date/time this recor... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/query_record.rb | Ruby | mit | 84 | main | 2,174 | # frozen_string_literal: true
# = Query Record Model
#
# Query Records store the parameters of recent user queries for quicker access.
# For certain nested queries, the inner and outer queries are stored as
# separate query_records.
#
# Used by MO's Query::Modules::ActiveRecord
#
# == Attributes
#
# id:: ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/banner.rb | Ruby | mit | 84 | main | 203 | # frozen_string_literal: true
class Banner < ApplicationRecord
validates :message, presence: true
# Returns the latest active banner
def self.current
order(created_at: :desc).first
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/name_tracker.rb | Ruby | mit | 84 | main | 2,582 | # frozen_string_literal: true
#
# = Name Tracker Model
#
# == Attributes
#
# id:: Locally unique numerical id, starting at 1
# updated_at:: Date/time it was last updated
# user:: User who created it
# name_id:: Id of name we're tracking.
# note_template:: Template for... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/external_site.rb | Ruby | mit | 84 | main | 1,929 | # frozen_string_literal: true
#
# = External Site Model
#
# == Attributes
#
# id:: Locally unique numerical id, starting at 1.
# name:: Name of website, e.g. "MycoPortal".
# project:: Project which talks about the website and whose members
# may edit external_links to th... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/language.rb | Ruby | mit | 84 | main | 3,836 | # frozen_string_literal: true
#
# = Language
#
# This model groups all the translations for a single locale.
#
# == Attributes
#
# locale:: Official locale string, e.g., "en".
# name:: Name of the language in that language, e.g., "English" or "Español"
# order:: Latinized version language name, e.g., "Russ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/observation_collection_number.rb | Ruby | mit | 84 | main | 205 | # frozen_string_literal: true
# Glue table between observations and collection_numbers.
class ObservationCollectionNumber < ApplicationRecord
belongs_to :observation
belongs_to :collection_number
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/occurrence.rb | Ruby | mit | 84 | main | 8,228 | # frozen_string_literal: true
#
# = Occurrence Model
#
# An Occurrence groups Observations of the same physical mushroom specimen.
# Typically created when multiple people independently observe the same
# specimen at large mushroom events.
#
# == Attributes
#
# id:: unique numerical id
# u... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/project_excluded_observation.rb | Ruby | mit | 84 | main | 263 | # frozen_string_literal: true
# Join table between projects and observations the project admin has
# excluded from the project's Updates tab candidate list.
class ProjectExcludedObservation < ApplicationRecord
belongs_to :project
belongs_to :observation
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/external_link.rb | Ruby | mit | 84 | main | 2,991 | # frozen_string_literal: true
#
# = External Link Model
#
# An external link is a URL attached to a single observation which links to a
# related record on an external site. It is associated with a record in the
# external_sites table, which potentially eventually among other things, tells
# the site who is allo... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/vote.rb | Ruby | mit | 84 | main | 8,885 | # frozen_string_literal: true
#
# = Vote Model
#
# Model describing a single vote for a single Naming. Methods for dealing
# with Vote's are all moved up to Naming or Observation::NamingConsensus,
# depending on whether all the information required for the operation is
# contained within a single Naming or not.
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/user_group.rb | Ruby | mit | 84 | main | 4,739 | # frozen_string_literal: true
#
# = User Group Model
#
# Model that describes a group of Users. It used to be pretty
# straight-forward. There are now two new classes of groups that muddy the
# waters: "all users" and "user N". The first contains all users, whether
# they are verified or not. The second is a ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/glossary_term.rb | Ruby | mit | 84 | main | 3,380 | # frozen_string_literal: true
# Glossary of mycological terms, with illustrations.
#
# NOTE: Glossary terms are attached to one or more images via the glue table
# glossary_term_images. This table includes the thumbnail!!!!
class GlossaryTerm < AbstractModel
require("acts_as_versioned")
belongs_to(:thumb_image,
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/rss_log.rb | Ruby | mit | 84 | main | 14,897 | # frozen_string_literal: true
# = RSS Log Model
#
# This model handles the RSS feed. Every object we care about gets an RssLog
# instance to report changes in that object. Going forward, every new object
# gets assigned one; historically, there are loads of objects without, but we
# don't really care, so they s... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/interest.rb | Ruby | mit | 84 | main | 3,659 | # frozen_string_literal: true
#
# = Interest Model
#
# Simple model for registering interest in arbitrary objects. Any User may
# register either positive interest ("watch") or negative interest ("ignore")
# in any object.
#
# In practice this means that the User receives some sort of notification
# whenever an... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/location_description_writer.rb | Ruby | mit | 84 | main | 207 | # frozen_string_literal: true
# Glue table between location_descriptions and user_groups.
class LocationDescriptionWriter < ApplicationRecord
belongs_to :location_description
belongs_to :user_group
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/user.rb | Ruby | mit | 84 | main | 42,883 | # frozen_string_literal: true
#
# = User Model
#
# Model describing a User.
#
# Login is handled by lib/login_system.rb, a third-party package that we've
# updated slightly. It is enforced by adding <tt>before_action
# :login_required</tt> filters to the controllers.
#
# We now support autologin or "remember me... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/validations.rb | Ruby | mit | 84 | main | 1,519 | # frozen_string_literal: true
# validations used by multiple objects
module Validations
# Validates obj.when.
# used by: Observation, SpeciesList
def validate_when(when_date, errors)
check_date(when_date, errors) &&
check_time(when_date, errors) &&
check_year(when_date, errors)
end
#########... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/triple.rb | Ruby | mit | 84 | main | 333 | # frozen_string_literal: true
class Triple < ApplicationRecord
def self.delete_predicate_matches(predicate)
return unless valid_predicate(predicate)
Triple.where(predicate: predicate).destroy_all
end
def self.valid_predicate(predicate)
predicate.match(/^:\w+$/)
end
private_class_method :valid_p... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/observation.rb | Ruby | mit | 84 | main | 45,689 | # frozen_string_literal: true
# = Observation Model
#
# An Observation is a mushroom seen at a certain Location and time, as
# recorded by a User. This is at the core of the site. It can have any
# number of Image's, Naming's, Comment's, Interest's.
#
# == Voting
#
# Voting is still in a state of flux. At the... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/field_slip.rb | Ruby | mit | 84 | main | 5,621 | # frozen_string_literal: true
# Attributes:
# code: string, unique code for field slip, starts with project prefix
class FieldSlip < AbstractModel
attr_reader :current_user
has_one :occurrence, dependent: :nullify
belongs_to :project
belongs_to :user
validates :user_id, presence: true
validates :code... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/inat_import.rb | Ruby | mit | 84 | main | 5,736 | # frozen_string_literal: true
# Encapsulates a single user's iNatImport
#
# == Attributes
#
# user:: user who initiated the iNat import
# state:: state of the import
# ended_at:: when the job was Done
# token:: token used to validate request; can be a c... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/location.rb | Ruby | mit | 84 | main | 28,705 | # frozen_string_literal: true
#
# = Location Model
#
# Model to describe a location. Locations are rectangular regions, not
# points, with an associated free-form description.
#
# == Version
#
# Changes are kept in the "location_versions" table using
# ActiveRecord::Acts::Versioned.
#
# == Attributes
#
# id::... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/synonym.rb | Ruby | mit | 84 | main | 1,729 | # frozen_string_literal: true
#
# = Synonym Model
#
# This model is used to group Names that have been synonymized. All it does
# is own two or more Names. That's it. Couldn't be easier. Actually it's a
# real mess, but all the complexity of merging synonyms, etc. is dealt with in
# Name.
#
# == Attributes
#... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/name_sorter.rb | Ruby | mit | 84 | main | 11,374 | # frozen_string_literal: true
#
# = Name Sorter
#
# This class is used by a few controllers (e.g. NameController,
# SpeciesListController) to help parse lists of names, such as in
# create/edit_species_list, and change_synonyms. It uses
# NameParse to parse individual lines, then gathers unrecognized names,
# ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/translation_string.rb | Ruby | mit | 84 | main | 3,941 | # frozen_string_literal: true
#
# = TranslationString
#
# Contains a single localization string.
#
# == Attributes
#
# language:: Language it belongs to.
# tag:: Globalite "tag", e.g., :app_title.
# text:: The actual text, e.g., "Mushroom Observer".
# version:: ActsAsVersioned version numb... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/sequence.rb | Ruby | mit | 84 | main | 9,540 | # frozen_string_literal: true
#
# = Sequence Model
#
# A nucleotide sequence associated with an Observation.
# A Sequence must have: a Locus, either Bases and/or (Archive and Accession).
# It may have Notes.
#
# == Attributes
#
# id:: unique numerical id, starting at 1.
# observation:: asso... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/herbarium_record.rb | Ruby | mit | 84 | main | 5,521 | # frozen_string_literal: true
#
# = HerbariumRecords Model
#
# Represents a record of a physical collection at an herbarium. Each time
# a specimen is accessioned at an herbarium it will be given a label and a
# unique identifier. This info can be stored in this record.
#
# Each HerbariumRecord belongs to an He... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/donation.rb | Ruby | mit | 84 | main | 572 | # frozen_string_literal: true
# Donations to Mushroom Observer, Inc.
class Donation < ApplicationRecord
belongs_to :user
def self.donor_list
values = Donation.where(anonymous: 0, reviewed: 1).group(:who, :email).
order(Donation[:amount].sum.desc,
Donation[:created_at].maximum.d... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/collection_number.rb | Ruby | mit | 84 | main | 4,794 | # frozen_string_literal: true
#
# = CollectionNumbers Model
#
# Represents a voucher specimen's collector and number. A single specimen
# can potentially have more than one collection number in strange cases, but
# usually it will be one-to-one. However there is no object in MO which
# represents a physical vou... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/description.rb | Ruby | mit | 84 | main | 17,636 | # frozen_string_literal: true
#
# = Base Class for Models with Authored Descriptions
#
# This class provides the common functionality between NameDescription and
# LocationDescription.
#
# == Class Methods
#
# None.
#
# == Instance Methods
#
# ==== Title formats
# text_name:: Description of Ag... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/article.rb | Ruby | mit | 84 | main | 2,449 | # frozen_string_literal: true
# Article
# Simple model used for news about MO, e.g., new releases
# New articles are added to the Acitivity feed
#
# == Attributes
#
# title:: headline
# id:: unique numerical id (starting at 1)
# rss_log_id:: unique numerical id
# created_at:: ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/visual_model.rb | Ruby | mit | 84 | main | 684 | # frozen_string_literal: true
class VisualModel < AbstractModel
has_many :visual_groups, dependent: :destroy
validates :name, presence: {
message: proc { :cannot_be_blank.t }
}
validates :name, format: {
without: /\t/, message: proc { :cannot_include_tabs.t }
}
def to_json(_)
{
name: na... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/project.rb | Ruby | mit | 84 | main | 22,390 | # frozen_string_literal: true
#
# = Project Model
#
# A Project is used to encapsulate a collaboration effort to write species
# descriptions. Technically, a Project is just defined as a UserGroup of
# members and a UserGroup of admins, which together own a collection of draft
# Name Descriptions.
#
# == Attrib... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/publication.rb | Ruby | mit | 84 | main | 1,143 | # frozen_string_literal: true
#
# = Publications Model
#
# Publications which cite or benefit from Mushroom Observer
#
# == Attributes
#
# id:: Locally unique numerical id, starting at 1.
# user_id:: id of user who created the entry
# full:: Full name of publication
# link:: U... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/copyright_change.rb | Ruby | mit | 84 | main | 1,995 | # frozen_string_literal: true
#
# = Copyright Change Model
#
# This model keeps track of change in copyright info in Image objects.
#
# NOTE: each entry records the state *before* the time given. If no
# entries are present, then the copyright has never changed.
#
# == Attributes
#
# id:: Locall... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/api_key.rb | Ruby | mit | 84 | main | 1,226 | # frozen_string_literal: true
class APIKey < AbstractModel
belongs_to :user
before_create :provide_defaults
scope :order_by_default,
-> { order_by(::Query::APIKeys.default_order) }
scope :notes_has,
->(phrase) { search_columns(APIKey[:notes], phrase) }
KEY_LENGTH = 32
def self.show_contr... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/user_stats.rb | Ruby | mit | 84 | main | 18,623 | # frozen_string_literal: true
# Keep track of each user's contributions
#
# == Class Methods
#
# update_contribution:: Callback that keeps User contribution up to date.
# refresh_all_user_stats:: Callback for cron jobs that refreshes this table.
#
# ==== Public
# get_user_data:: Returns stats fo... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/application_record.rb | Ruby | mit | 84 | main | 207 | # frozen_string_literal: true
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
require("arel-helpers")
include ArelHelpers::ArelTable
include ArelHelpers::JoinAssociation
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/language_exporter.rb | Ruby | mit | 84 | main | 12,962 | # frozen_string_literal: true
#
# = Language Localization and Export Files
#
# Translation strings (also called "localization strings" in places) are
# exported to two types of files:
#
# === Localization files
#
# YAML files: <tt>config/locales/en.yml</tt>
# These are written automatically and should never be e... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/language_tracking.rb | Ruby | mit | 84 | main | 2,852 | # frozen_string_literal: true
#
# = Tracking Usage of Translations
#
# Simple global mechanism for tracking which localization strings get used on
# a given page. You would enable it in a +before_action+ in your controller,
# then Symbol#localize will have it make note of each tag that gets used
# throughout the... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/observation_herbarium_record.rb | Ruby | mit | 84 | main | 202 | # frozen_string_literal: true
# Glue table between observations and herbarium_records.
class ObservationHerbariumRecord < ApplicationRecord
belongs_to :observation
belongs_to :herbarium_record
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/observation_view.rb | Ruby | mit | 84 | main | 1,279 | # frozen_string_literal: true
# Keep track of when each user last viewed each observation, as well as
# whether they've marked it as `reviewed` (in help identify) or voted on
# a naming of that obs (indicating reviewed)
# == Attributes
#
# observation_id:: ID of the observation.
# user_id:: ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/image_vote.rb | Ruby | mit | 84 | main | 964 | # frozen_string_literal: true
#
# = Image Vote Model
#
# Model describing a single vote for a single Image. Most of the time views and
# actions will use methods in Image to query and modify image votes. See:
#
# Image#vote_cache:: Average vote for this Image.
# Image#users_vote:: Return a given User's Image... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/name_parse.rb | Ruby | mit | 84 | main | 4,001 | # frozen_string_literal: true
#
# = Name Parser
#
# This class is used by NameSorter and a few controllers (e.g.
# NameController, SpeciesListController) to help parse lists of names, such as
# in create/edit_species_list, and change_synonyms. It splits
# each line up into a name and an optional synonym:
#
# ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/species_list.rb | Ruby | mit | 84 | main | 17,462 | # frozen_string_literal: true
#
# = Observation List Model (were originally called Species Lists)
#
# A SpeciesList is a list of Observations (*not* Names's). Various User's
# have used them -- among other things -- to:
#
# 1. Gather all the Observation's at a given Location or region.
# 2. Gather all the Observ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/visual_group_image.rb | Ruby | mit | 84 | main | 278 | # frozen_string_literal: true
# Glue table between observations and images.
class VisualGroupImage < ApplicationRecord
belongs_to :visual_group
belongs_to :image
def image_in_group?(visual_group_id)
image.visual_groups.pluck(:id).include?(visual_group_id)
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/observation/merged_naming.rb | Ruby | mit | 84 | main | 4,124 | # frozen_string_literal: true
# Observation::MergedNaming
#
# Wraps one or more Naming records that share the same name_id within
# an occurrence. Presents a unified interface for the namings panel,
# deduplicating by name while aggregating votes and reasons.
#
class Observation::MergedNaming
attr_reader :name_id, :... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/observation/naming_consensus.rb | Ruby | mit | 84 | main | 18,285 | # frozen_string_literal: true
# Observation::NamingConsensus
#
# This PORO isolates the code that determines the current state of naming/
# voting on an obs, and handles naming and voting changes on observations.
#
# Instantiate a NamingConsensus to get a snapshot of the current state, or to
# perform changes to that ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/observation/consensus_calculator.rb | Ruby | mit | 84 | main | 10,120 | # frozen_string_literal: true
class Observation
class ConsensusCalculator
def initialize(namings)
@namings = namings.includes(:name, votes: [:observation, :user])
@name_votes = {} # Strongest vote for a given name for a user.
@taxon_votes = {} # Strongest vote for any names in a group of... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/observation/scopes.rb | Ruby | mit | 84 | main | 27,284 | # frozen_string_literal: true
module Observation::Scopes # rubocop:disable Metrics/ModuleLength
# This is using Concern so we can define the scopes in this included module.
extend ActiveSupport::Concern
# Confidence levels for vote_cache filtering
CONFIDENCE_LEVELS = [3.0, 2.0, 1.0, 0.0, -1.0, -2.0, -3.0].fre... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/name/resolve.rb | Ruby | mit | 84 | main | 2,682 | # frozen_string_literal: true
module Name::Resolve
# When we `include` a module, the way to add class methods is like this:
def self.included(base)
base.extend(ClassMethods)
end
def save_with_log(user, log = nil, args = {})
return false unless changed?
log ||= :log_name_updated
args = { touch... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/name/notify.rb | Ruby | mit | 84 | main | 3,989 | # frozen_string_literal: true
module Name::Notify
attr_writer :skip_notify
def skip_notify
@skip_notify || false
end
# Notify webmaster that a new name was created.
# Migrated from QueuedEmail::Webmaster to ActionMailer + ActiveJob.
def notify_webmaster
return if skip_notify
message = Webmas... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/name/validation.rb | Ruby | mit | 84 | main | 4,592 | # frozen_string_literal: true
module Name::Validation
# When we `include` a module, the way to add class methods is like this:
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
# :string field size limits in characters, based on this algorithm:
# Theoretical max differences... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/name/synonymy.rb | Ruby | mit | 84 | main | 7,085 | # frozen_string_literal: true
module Name::Synonymy
# Returns "Deprecated" or "Valid" in the local language.
def status
deprecated ? :DEPRECATED.l : :ACCEPTED.l
end
# Returns an Array of all synonym Name's including itself at front of list.
# (This looks screwy, but I think it is the safest way to handl... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/name/taxonomy.rb | Ruby | mit | 84 | main | 24,186 | # frozen_string_literal: true
module Name::Taxonomy
# When we `include` a module, the way to add class methods is like this:
def self.included(base)
base.extend(ClassMethods)
end
def at_or_below_genus?
rank == "Genus" || below_genus?
end
def above_genus?
Name.ranks_above_genus.include?(rank)
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/name/spelling.rb | Ruby | mit | 84 | main | 6,789 | # frozen_string_literal: true
module Name::Spelling
# When we `include` a module, the way to add class methods is like this:
def self.included(base)
base.extend(ClassMethods)
end
# Is this Name misspelled?
def is_misspelling?
!correctly_spelt?
end
def correctly_spelt?
correct_spelling_id.bl... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/name/observations.rb | Ruby | mit | 84 | main | 2,029 | # frozen_string_literal: true
class Name
# The goal of this class is to reduce the number of repetitive queries
# on the Name show page that counted the results for each variant of
# "observations of this name". These each originally did separate queries.
# This class instead does a single query for `@all` obs... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/name/format.rb | Ruby | mit | 84 | main | 8,376 | # frozen_string_literal: true
module Name::Format
GROUP_AT_END_OF_TEXT_NAME = / #{Name::Parse::GROUP_ABBR}$/
# When we `include` a module, the way to add class methods is like this:
def self.included(base)
base.extend(ClassMethods)
end
##### Display of names #############################################... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/name/lifeform.rb | Ruby | mit | 84 | main | 3,361 | # frozen_string_literal: true
module Name::Lifeform
# When we `include` a module, the way to add class methods is like this:
def self.included(base)
base.extend(ClassMethods)
end
ALL_LIFEFORMS = %w[
basidiolichen
lichen
lichen_ally
lichenicolous
].freeze
module ClassMethods
def al... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/name/propagate_generic_classifications.rb | Ruby | mit | 84 | main | 4,433 | # frozen_string_literal: true
module Name::PropagateGenericClassifications
def can_propagate?
rank == "Genus" &&
# Name s.l. might have a broader classifications than name s.l.
# So prevent propagation in order to protect subtaxa classification
author.exclude?("sensu lato")
end
# When we `... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/name/create.rb | Ruby | mit | 84 | main | 6,174 | # frozen_string_literal: true
# Usage: in class Name, `extend Create`, not `include Create`.
# Extending makes these module methods into class methods of Name.
module Name::Create
# Shorthand for calling Name.find_names with +fill_in_authors: true+.
def find_names_filling_in_authors(user, in_str, rank = nil,
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/name/parse.rb | Ruby | mit | 84 | main | 24,260 | # frozen_string_literal: true
# Usage: in class Name, `extend Parse`, not `include Parse`.
# Extending makes these module methods into class methods of Name.
module Name::Parse
# RankMatcher:: Lighweight class used to get ranks from text strings
# Use:
# XXX_MATCHERS = [RankMatcher.new(:Rank1, /regexp1/),
# ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/name/scopes.rb | Ruby | mit | 84 | main | 13,647 | # frozen_string_literal: true
# ==== Scopes
# created_at("yyyy-mm-dd", "yyyy-mm-dd")
# updated_at("yyyy-mm-dd", "yyyy-mm-dd")
# deprecated
# has_description
# with_correct_spelling
# with_incorrect_spelling
# with_self_referential_misspelling
# has_synonyms
# ok_for_export
# rank(ranks)
# with_rank(rank)
#... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/name/merge.rb | Ruby | mit | 84 | main | 4,482 | # frozen_string_literal: true
# Combine two Name objects (and associations) into one
class Name
module Merge
# Would merger into another Name destroy data in the sense that the
# merger could not be uncrambled? If any information will get
# lost we return true.
# It's "destrutive" if:
# - has Nam... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/name/change.rb | Ruby | mit | 84 | main | 3,620 | # frozen_string_literal: true
module Name::Change
# Changes the name, and creates parents as necessary. Throws a RuntimeError
# with error message if unsuccessful in any way. Returns nothing. *UNSAVED*!!
#
# *NOTE*: It does not save the changes to itself, but if it has to create or
# update any parents (an... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/name/parse/parsed_name.rb | Ruby | mit | 84 | main | 1,190 | # frozen_string_literal: true
# parsing a string to a Name
class Name::Parse::ParsedName
attr_accessor :text_name, :search_name, :sort_name, :display_name
attr_accessor :rank, :author, :parent_name
def initialize(params)
@text_name = params[:text_name]
@search_name = params[:search_name]
@sort_name ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/mappable/minimal_observation.rb | Ruby | mit | 84 | main | 2,714 | # frozen_string_literal: true
module Mappable
class MinimalObservation
include ActiveModel::Model
include ActiveModel::Attributes
include Mappable::BoxMethods
attribute :id, :integer
attribute :lat, :float
attribute :lng, :float
attribute :location_id, :integer
attribute :location, L... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/mappable/box.rb | Ruby | mit | 84 | main | 2,182 | # frozen_string_literal: true
# Non-AR model Box represents a geographic bounding box, a rectangle on the
# surface of the earth, with borders: north, south, east, west
# Used mostly by model scopes, and for area comparisons.
#
# == Instance methods
#
# valid?:: Return true if box is valid.
# expand(de... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/mappable/minimal_location.rb | Ruby | mit | 84 | main | 373 | # frozen_string_literal: true
module Mappable
class MinimalLocation < Box
attribute :id, :integer
attribute :name, :string
validates :id, presence: true
validates :name, presence: true
def display_name
if ::User.current_location_format == "scientific"
::Location.reverse_name(name)... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/description/scopes.rb | Ruby | mit | 84 | main | 1,021 | # frozen_string_literal: true
module Description::Scopes
# This is using Concern so we can define the scopes in this included module.
extend ActiveSupport::Concern
# NOTE: To improve Coveralls display, avoid one-line stabby lambda scopes.
# Two line stabby lambdas are OK, it's just the declaration line that w... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | app/models/vote/weight_boost.rb | Ruby | mit | 84 | main | 1,565 | # frozen_string_literal: true
# Vote::WeightBoost
#
# Computes effective vote weights with the sub-max vote boost
# (Issue #3815). When a user's highest vote is positive but below
# MAXIMUM_VOTE, equals their max across all namings, and the
# naming already has a higher vote from someone else, the weight
# is reduced ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.