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
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/paypal/paypal_charge.rb
Ruby
mit
8,966
main
4,794
# frozen_string_literal: true class PaypalCharge < BaseProcessorCharge include CurrencyHelper attr_accessor :paypal_payment_status, :card_visual def initialize(paypal_transaction_id:, order_api_used:, payment_details: {}) self.charge_processor_id = PaypalChargeProcessor.charge_processor_id self.id = pa...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/paypal/helpers/paypal_api_error_code_range.rb
Ruby
mit
8,966
main
300
# frozen_string_literal: true module PaypalApiErrorCodeRange GENERAL_VALIDATION = (81_000..99_998) UNAVAILABLE = (10_002..10_101) CAPTURE_INTERNAL = (10_001..10_482) PAYMENT_INSTRUMENT_FAILURE = (10_486..20_000) REFUND_VALIDATION = (10_001..10_406) REFUND_FAILURE = (10_414..13_751) end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/errors/charge_processor_card_error.rb
Ruby
mit
8,966
main
307
# frozen_string_literal: true class ChargeProcessorCardError < ChargeProcessorError attr_reader :error_code, :charge_id def initialize(error_code, message = nil, original_error: nil, charge_id: nil) @error_code = error_code @charge_id = charge_id super(message, original_error:) end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/errors/charge_processor_error_generic.rb
Ruby
mit
8,966
main
254
# frozen_string_literal: true class ChargeProcessorErrorGeneric < ChargeProcessorError attr_reader :error_code def initialize(error_code, message: nil, original_error: nil) @error_code = error_code super(message, original_error:) end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/transfers/stripe/stripe_transfer_affiliate_credits.rb
Ruby
mit
8,966
main
1,380
# frozen_string_literal: false # Handles moving money around internally from Gumroad's Stripe # account, into Stripe managed accounts. Transfers should be performed # using the functions on this account rather than directly creating # Stripe::Transfer objects, since transfers created here are logged to # Slack rooms w...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/transfers/stripe/stripe_transfer_externally_to_gumroad.rb
Ruby
mit
8,966
main
1,895
# frozen_string_literal: true # Handles moving money for the Gumroad main Stripe account. # Provides information about how much money is in the Stripe # balance, and functionality to move money from the Stripe balance # to Gumroad's bank account. module StripeTransferExternallyToGumroad # Maximum amount Stripe is ab...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/transfers/stripe/stripe_transfer_internally_to_creator.rb
Ruby
mit
8,966
main
1,098
# frozen_string_literal: true # Handles moving money around internally from Gumroad's Stripe # account, into Stripe managed accounts. Transfers should be performed # using the functions on this account rather than directly creating # Stripe::Transfer objects, since transfers created here are logged to # Slack rooms wi...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/payouts/payout_estimates.rb
Ruby
mit
8,966
main
1,424
# frozen_string_literal: true module PayoutEstimates def self.estimate_held_amount_cents(date, processor_type) payment_estimates = estimate_payments_for_balances_up_to_date_for_users(date, processor_type, User.holding_balance) holder_of_funds_amount_cents = Hash.new(0) payment_estimates.each do |payment_...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/payouts/payouts.rb
Ruby
mit
8,966
main
8,364
# frozen_string_literal: true class Payouts extend ActionView::Helpers::NumberHelper MIN_AMOUNT_CENTS = 100_00 PAYOUT_TYPE_STANDARD = "standard" PAYOUT_TYPE_INSTANT = "instant" def self.is_user_payable(user, date, processor_type: nil, add_comment: false, from_admin: false, payout_type: Payouts::PAYOUT_TYPE...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/payouts/payout_processor_type.rb
Ruby
mit
8,966
main
558
# frozen_string_literal: true module PayoutProcessorType PAYPAL = "PAYPAL" ACH = "ACH" # Retired. Kept because we still have payments in the database for this processor. ZENGIN = "ZENGIN" # Retired. Kept because we still have payments in the database for this processor, and validations for them. STRIPE = "STRI...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/payouts/processor/stripe/stripe_payout_processor.rb
Ruby
mit
8,966
main
22,068
# frozen_string_literal: true class StripePayoutProcessor extend CurrencyHelper DEBIT_CARD_PAYOUT_MAX = 300_000 INSTANT_PAYOUT_FEE_PERCENT = 3 MINIMUM_INSTANT_PAYOUT_AMOUNT_CENTS = 100_00 MAXIMUM_INSTANT_PAYOUT_AMOUNT_CENTS = 9_999_00 # Public: Determines if it's possible for this processor to payout #...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/payouts/processor/paypal/paypal_payout_processor.rb
Ruby
mit
8,966
main
23,429
# frozen_string_literal: true class PaypalPayoutProcessor # We would split up the payment into chunks of at most this size, only when necessary, in order to get around the MassPay API limitations. # See perform_payment_in_split_mode. This is a hack that should be replaced with a proper split payout mechanism that ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/jobs/delete_unused_public_files_job.rb
Ruby
mit
8,966
main
705
# frozen_string_literal: true class DeleteUnusedPublicFilesJob include Sidekiq::Job sidekiq_options queue: :low, retry: 3 def perform PublicFile .alive .with_attached_file .where("scheduled_for_deletion_at < ?", Time.current) .find_in_batches do |batch| ReplicaLagWatcher.wat...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/mailers/admin_mailer.rb
Ruby
mit
8,966
main
1,003
# frozen_string_literal: true class AdminMailer < ApplicationMailer SUBJECT_PREFIX = ("[#{Rails.env}] " unless Rails.env.production?) default from: ADMIN_EMAIL default to: DEVELOPERS_EMAIL layout "layouts/email" def chargeback_notify(dispute_id) dispute = Dispute.find(dispute_id) @disputable = dis...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/mailers/creator_mailer.rb
Ruby
mit
8,966
main
1,975
# frozen_string_literal: true class CreatorMailer < ApplicationMailer helper MailerHelper helper ApplicationHelper helper CurrencyHelper layout "layouts/email" def gumroad_day_fee_saved(seller_id:, to_email: nil) @announcement = true seller = User.find(seller_id) email = to_email.presence || se...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/mailers/internal_notification_mailer.rb
Ruby
mit
8,966
main
573
# frozen_string_literal: true class InternalNotificationMailer < ApplicationMailer SUBJECT_PREFIX = ("[#{Rails.env}] " unless Rails.env.production?) default from: NOREPLY_EMAIL def notify(room_name:, sender:, message_text:, attachments_data: []) @sender = sender @message_text = message_text @room_n...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/mailers/team_mailer.rb
Ruby
mit
8,966
main
1,085
# frozen_string_literal: true class TeamMailer < ApplicationMailer include ActionView::Helpers::SanitizeHelper layout "layouts/email" def invite(team_invitation) @team_invitation = team_invitation @seller = team_invitation.seller @seller_name = sanitize(team_invitation.seller.display_name) @sel...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/mailers/affiliate_request_mailer.rb
Ruby
mit
8,966
main
3,229
# frozen_string_literal: true class AffiliateRequestMailer < ApplicationMailer layout "layouts/email" default from: "noreply@#{CUSTOMERS_MAIL_DOMAIN}" def notify_requester_of_request_submission(affiliate_request_id) @affiliate_request = AffiliateRequest.find(affiliate_request_id) @subject = "Your app...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/mailers/service_mailer.rb
Ruby
mit
8,966
main
659
# frozen_string_literal: true class ServiceMailer < ApplicationMailer after_action :deliver_email layout "layouts/email" # service charge emails def service_charge_receipt(service_charge_id) @service_charge = ServiceCharge.find(service_charge_id) @user = @service_charge.user @subject = "Gumroad ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/mailers/merchant_registration_mailer.rb
Ruby
mit
8,966
main
1,949
# frozen_string_literal: true class MerchantRegistrationMailer < ApplicationMailer default from: ADMIN_EMAIL layout "layouts/email" def account_deauthorized_to_user(user_id, charge_processor_id) @user = User.find(user_id) @charge_processor_display_name = ChargeProcessor::DISPLAY_NAME_MAP[charge_process...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/mailers/follower_mailer.rb
Ruby
mit
8,966
main
600
# frozen_string_literal: true class FollowerMailer < ApplicationMailer layout "layouts/email" default from: "Gumroad <noreply@#{FOLLOWER_CONFIRMATION_MAIL_DOMAIN}>" def confirm_follower(followed_user_id, follower_id) @follower = Follower.find(follower_id) @followed_username = User.find(followed_user_id)...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/mailers/contacting_creator_mailer.rb
Ruby
mit
8,966
main
22,215
# frozen_string_literal: true class ContactingCreatorMailer < ApplicationMailer include ActionView::Helpers::NumberHelper include ActionView::Helpers::TagHelper include ActionView::Helpers::UrlHelper include ActionView::Helpers::TextHelper include CurrencyHelper include CustomMailerRouteBuilder include S...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/mailers/accounting_mailer.rb
Ruby
mit
8,966
main
5,155
# frozen_string_literal: true require "csv" class AccountingMailer < ApplicationMailer SUBJECT_PREFIX = ("[#{Rails.env}] " unless Rails.env.production?) default from: ADMIN_EMAIL_WITH_NAME layout "layouts/email" def funds_received_report(month, year) WithMaxExecutionTime.timeout_queries(seconds: 1.hour)...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/mailers/comment_mailer.rb
Ruby
mit
8,966
main
524
# frozen_string_literal: true class CommentMailer < ApplicationMailer layout "layouts/email" default from: "noreply@#{CREATOR_CONTACTING_CUSTOMERS_MAIL_DOMAIN}" def notify_seller_of_new_comment(comment_id) @comment = Comment.includes(:commentable).find(comment_id) subject = "New comment on #{@comment....
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/mailers/application_mailer.rb
Ruby
mit
8,966
main
2,134
# frozen_string_literal: true class ApplicationMailer < ActionMailer::Base include RescueSmtpErrors, MailerHelper helper MailerHelper # Constants for Gumroad emails { ADMIN_EMAIL: "hi@#{DEFAULT_EMAIL_DOMAIN}", DEVELOPERS_EMAIL: "developers@#{DEFAULT_EMAIL_DOMAIN}", NOREPLY_EMAIL: "noreply@#{DEFAUL...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/mailers/customer_mailer.rb
Ruby
mit
8,966
main
11,331
# frozen_string_literal: true class CustomerMailer < ApplicationMailer include CurrencyHelper helper CurrencyHelper helper PreorderHelper helper ProductsHelper helper ApplicationHelper layout "layouts/email", except: :send_to_kindle def grouped_receipt(purchase_ids) @chargeables = Purchase.where(id...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/mailers/affiliate_mailer.rb
Ruby
mit
8,966
main
8,547
# frozen_string_literal: true class AffiliateMailer < ApplicationMailer include NotifyOfSaleHeaders include ActionView::Helpers::TextHelper include BasePrice::Recurrence layout "layouts/email" COLLABORATOR_MAX_PRODUCTS = 5 def direct_affiliate_invitation(affiliate_id, prevent_sending_invitation_email_to...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/mailers/one_off_mailer.rb
Ruby
mit
8,966
main
1,299
# frozen_string_literal: true class OneOffMailer < ApplicationMailer helper InstallmentsHelper layout "layouts/email" # Mailer used to send one-off emails to user, usually via Rails console # `from` email address is not being monitored. If you need to receive replies from users, pass the optional # param `...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/mailers/customer_low_priority_mailer.rb
Ruby
mit
8,966
main
18,327
# frozen_string_literal: true class CustomerLowPriorityMailer < ApplicationMailer include CurrencyHelper helper PreorderHelper helper ProductsHelper include ActionView::Helpers::TextHelper default from: "Gumroad <noreply@#{CUSTOMERS_MAIL_DOMAIN}>" after_action :deliver_subscription_email, only: %i[subscri...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/mailers/community_chat_recap_mailer.rb
Ruby
mit
8,966
main
1,710
# frozen_string_literal: true class CommunityChatRecapMailer < ApplicationMailer include ActionView::Helpers::TextHelper layout "layouts/email" default from: "noreply@#{CREATOR_CONTACTING_CUSTOMERS_MAIL_DOMAIN}" def community_chat_recap_notification(user_id, seller_id, community_chat_recap_ids) user = U...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/mailers/user_signup_mailer.rb
Ruby
mit
8,966
main
331
# frozen_string_literal: true class UserSignupMailer < Devise::Mailer include RescueSmtpErrors helper MailerHelper layout "layouts/email" def email_changed(record, opts = {}) opts[:from] = ApplicationMailer::NOREPLY_EMAIL_WITH_NAME opts[:reply_to] = ApplicationMailer::NOREPLY_EMAIL_WITH_NAME super...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/mailers/invite_mailer.rb
Ruby
mit
8,966
main
593
# frozen_string_literal: true class InviteMailer < ApplicationMailer layout "layouts/email" def receiver_signed_up(invite_id) @invite = Invite.find(invite_id) @sender = User.find(@invite.sender_id) @receiver = User.find(@invite.receiver_id) @subject = if @receiver.name.present? "#{@rece...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/mailers/two_factor_authentication_mailer.rb
Ruby
mit
8,966
main
1,160
# frozen_string_literal: true class TwoFactorAuthenticationMailer < ApplicationMailer after_action :deliver_email after_action :record_email_sent layout "layouts/email" # TODO(ershad): Remove this once the issue with Resend is resolved default delivery_method_options: -> { MailerInfo.default_delivery_metho...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/mailers/concerns/notify_of_sale_headers.rb
Ruby
mit
8,966
main
1,793
# frozen_string_literal: true module NotifyOfSaleHeaders extend ActiveSupport::Concern def set_notify_of_sale_headers(is_preorder:) formatted_price = @price || @purchase.try(:formatted_total_price) if @product.is_recurring_billing if @purchase.try(:is_upgrade_purchase) @mail_heading = @subje...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/mailers/concerns/rescue_smtp_errors.rb
Ruby
mit
8,966
main
498
# frozen_string_literal: true module RescueSmtpErrors extend ActiveSupport::Concern included do rescue_from ArgumentError do |exception| if exception.message.include? "SMTP To address may not be blank" Rails.logger.error "Mailer Error: #{exception.inspect}" else raise exception ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/mailers/concerns/custom_mailer_route_builder.rb
Ruby
mit
8,966
main
652
# frozen_string_literal: true module CustomMailerRouteBuilder extend ActiveSupport::Concern def build_mailer_post_route(post:, purchase: nil) return unless post.shown_on_profile? && post.slug.present? user = post.user if user.custom_domain.present? custom_domain_view_post_url( slug: post...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/validators/email_format_validator.rb
Ruby
mit
8,966
main
1,295
# frozen_string_literal: true class EmailFormatValidator < ActiveModel::EachValidator # To reduce invalid email address errors, we enforcing the same email regex as the front end EMAIL_REGEX = /\A(?=.{3,255}$)( # between 3 and 255 characters ([^@\s()\[\],.<>;...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/validators/not_reserved_email_domain_validator.rb
Ruby
mit
8,966
main
595
# frozen_string_literal: true class NotReservedEmailDomainValidator < ActiveModel::EachValidator RESERVED_EMAIL_DOMAINS = %w[gumroad.com gumroad.org gumroad.dev].freeze class << self def domain_reserved?(email) return false if email.blank? domain = Mail::Address.new(email).domain domain&.do...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/validators/json_validator.rb
Ruby
mit
8,966
main
273
# frozen_string_literal: true class JsonValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) unless JSON::Validator.validate(options[:schema], value) record.errors.add(attribute, options[:message] || "invalid.") end end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/validators/isbn_validator.rb
Ruby
mit
8,966
main
987
# frozen_string_literal: true class IsbnValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) return if value.nil? && options[:allow_nil] return if value.blank? && options[:allow_blank] isbn_digits = value.delete("-") valid = if isbn_digits.length == 10 va...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/validators/disposable_email_validator.rb
Ruby
mit
8,966
main
1,019
# frozen_string_literal: true class DisposableEmailValidator < ActiveModel::EachValidator DISPOSABLE_DOMAINS_PATH = Rails.root.join("lib/data/disposable_email_domains.txt") class << self def disposable_domains @disposable_domains ||= load_domains end def disposable?(email) return false if...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/installment_policy.rb
Ruby
mit
8,966
main
858
# frozen_string_literal: true # Posts section # class InstallmentPolicy < ApplicationPolicy def index? user.role_accountant_for?(seller) || user.role_admin_for?(seller) || user.role_marketing_for?(seller) || user.role_support_for?(seller) end def create? user.role_admin_for?(seller) || u...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/collaborator_invitation_policy.rb
Ruby
mit
8,966
main
231
# frozen_string_literal: true class CollaboratorInvitationPolicy < ApplicationPolicy def accept? user.role_admin_for?(seller) && record.collaborator.affiliate_user == seller end def decline? accept? end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/imported_customer_policy.rb
Ruby
mit
8,966
main
544
# frozen_string_literal: true # Audience > Customers # class ImportedCustomerPolicy < ApplicationPolicy def index? user.role_accountant_for?(seller) || user.role_admin_for?(seller) || user.role_marketing_for?(seller) || user.role_support_for?(seller) end def update? # Actual purchase is not ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/s3_utility_policy.rb
Ruby
mit
8,966
main
355
# frozen_string_literal: true # Products > Edit product class S3UtilityPolicy < ApplicationPolicy def generate_multipart_signature? user.role_admin_for?(seller) || user.role_marketing_for?(seller) end def current_utc_time_string? generate_multipart_signature? end def cdn_url_for_blob? gener...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/churn_policy.rb
Ruby
mit
8,966
main
320
# frozen_string_literal: true class ChurnPolicy < ApplicationPolicy def show? Feature.active?(:churn_analytics_enabled, seller) && ( user.role_admin_for?(seller) || user.role_marketing_for?(seller) || user.role_support_for?(seller) || user.role_accountant_for?(seller) ) end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/service_charge_policy.rb
Ruby
mit
8,966
main
306
# frozen_string_literal: true class ServiceChargePolicy < ApplicationPolicy def create? user.role_owner_for?(seller) end def confirm? create? end def resend_receipt? create? end def send_invoice? create? end def generate_service_charge_invoice? create? end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/thumbnail_policy.rb
Ruby
mit
8,966
main
230
# frozen_string_literal: true # Products > Edit product class ThumbnailPolicy < ApplicationPolicy def create? user.role_admin_for?(seller) || user.role_marketing_for?(seller) end def destroy? create? end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/wishlist_policy.rb
Ruby
mit
8,966
main
271
# frozen_string_literal: true class WishlistPolicy < ApplicationPolicy def index? user.role_owner_for?(seller) end def create? index? end def update? index? && record.user == user end def destroy? index? && record.user == user end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/purchase_policy.rb
Ruby
mit
8,966
main
248
# frozen_string_literal: true # Library section # class PurchasePolicy < ApplicationPolicy def index? user.role_owner_for?(seller) end def archive? index? end def unarchive? index? end def delete? index? end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/community_chat_message_policy.rb
Ruby
mit
8,966
main
231
# frozen_string_literal: true class CommunityChatMessagePolicy < ApplicationPolicy def update? user.id == record.user_id end def destroy? user.id == record.user_id || user.id == record.community.seller_id end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/product_review_video_policy.rb
Ruby
mit
8,966
main
672
# frozen_string_literal: true class ProductReviewVideoPolicy < ApplicationPolicy def approve? role_permitted? && owned_by_seller?(record) end def reject? approve? end def stream? return true if record.approved? purchased_by_user?(record) || owned_by_seller?(record) end private def ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/call_policy.rb
Ruby
mit
8,966
main
247
# frozen_string_literal: true class CallPolicy < ApplicationPolicy def update? (user.role_admin_for?(seller) || user.role_support_for?(seller)) && record.purchase.seller == seller end def permitted_attributes [:call_url] end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/wishlist_follower_policy.rb
Ruby
mit
8,966
main
203
# frozen_string_literal: true class WishlistFollowerPolicy < ApplicationPolicy def create? user.role_owner_for?(seller) end def destroy? create? && record.follower_user == user end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/affiliate_request_policy.rb
Ruby
mit
8,966
main
215
# frozen_string_literal: true class AffiliateRequestPolicy < ApplicationPolicy def update? user.role_admin_for?(seller) || user.role_marketing_for?(seller) end def approve_all? update? end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/community_policy.rb
Ruby
mit
8,966
main
212
# frozen_string_literal: true class CommunityPolicy < ApplicationPolicy def index? user.accessible_communities_ids.any? end def show? user.accessible_communities_ids.include?(record.id) end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/workflow_policy.rb
Ruby
mit
8,966
main
750
# frozen_string_literal: true # Associated with Posts section # class WorkflowPolicy < ApplicationPolicy def index? user.role_accountant_for?(seller) || user.role_admin_for?(seller) || user.role_marketing_for?(seller) || user.role_support_for?(seller) end def create? user.role_admin_for?(sel...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/collaborator_policy.rb
Ruby
mit
8,966
main
471
# frozen_string_literal: true class CollaboratorPolicy < ApplicationPolicy def index? user.role_admin_for?(seller) end def create? index? end def new? index? end def edit? index? && when_record_available { record.seller == seller } end def update? edit? end def destroy? ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/comment_context.rb
Ruby
mit
8,966
main
242
# frozen_string_literal: true class CommentContext attr_reader :comment, :commentable, :purchase def initialize(comment:, commentable:, purchase:) @comment = comment @commentable = commentable @purchase = purchase end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/dashboard_policy.rb
Ruby
mit
8,966
main
474
# frozen_string_literal: true class DashboardPolicy < ApplicationPolicy def index? user.role_accountant_for?(seller) || user.role_admin_for?(seller) || user.role_marketing_for?(seller) || user.role_support_for?(seller) end def customers_count? = index? def total_revenue? = index? def active_...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/balance_policy.rb
Ruby
mit
8,966
main
242
# frozen_string_literal: true class BalancePolicy < ApplicationPolicy def index? user.role_accountant_for?(seller) || user.role_admin_for?(seller) || user.role_support_for?(seller) end def export? index? end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/comment_context_policy.rb
Ruby
mit
8,966
main
2,987
# frozen_string_literal: true # Does not inherit from ApplicationPolicy as this policy is used in a context where user is not authenticated, # like CommentsController # This is an exception from all other policies that are used within an authenticated area (where user and seller # are set) # # Associated with Posts se...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/dropbox_files_policy.rb
Ruby
mit
8,966
main
271
# frozen_string_literal: true # Products > Edit product class DropboxFilesPolicy < ApplicationPolicy def create? user.role_admin_for?(seller) || user.role_marketing_for?(seller) end def index? create? end def cancel_upload? create? end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/product_review_response_policy.rb
Ruby
mit
8,966
main
485
# frozen_string_literal: true class ProductReviewResponsePolicy < ApplicationPolicy def update? role_permitted? && owned_by_seller? end def destroy? role_permitted? && owned_by_seller? end private def role_permitted? user.role_owner_for?(seller) || user.role_admin_for?(seller) || ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/profile_section_policy.rb
Ruby
mit
8,966
main
569
# frozen_string_literal: true class ProfileSectionPolicy < ApplicationPolicy def create? = update? def update? user.role_admin_for?(seller) || user.role_marketing_for?(seller) end def destroy? = update? def permitted_attributes_for_create [:type, :product_id, *permitted_attributes_for_update] ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/subscription_policy.rb
Ruby
mit
8,966
main
309
# frozen_string_literal: true # Audience > Customers # class SubscriptionPolicy < ApplicationPolicy # Should match Audience::PurchasePolicy#update? def unsubscribe_by_seller? return false if record.link.user != seller user.role_admin_for?(seller) || user.role_support_for?(seller) end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/audience_policy.rb
Ruby
mit
8,966
main
279
# frozen_string_literal: true class AudiencePolicy < ApplicationPolicy def index? user.role_admin_for?(seller) || user.role_marketing_for?(seller) || user.role_support_for?(seller) || user.role_accountant_for?(seller) end def export? index? end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/link_policy.rb
Ruby
mit
8,966
main
5,100
# frozen_string_literal: true # Products section class LinkPolicy < ApplicationPolicy def index? user.role_accountant_for?(seller) || user.role_admin_for?(seller) || user.role_marketing_for?(seller) || user.role_support_for?(seller) end def new? user.role_admin_for?(seller) || user.role_...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/analytics_policy.rb
Ruby
mit
8,966
main
248
# frozen_string_literal: true class AnalyticsPolicy < ApplicationPolicy def index? user.role_admin_for?(seller) || user.role_marketing_for?(seller) || user.role_support_for?(seller) || user.role_accountant_for?(seller) end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/wishlist_product_policy.rb
Ruby
mit
8,966
main
327
# frozen_string_literal: true class WishlistProductPolicy < ApplicationPolicy def index? user.role_owner_for?(seller) end def create? index? end def destroy? index? && record.wishlist.user == user end def permitted_attributes [:product_id, :quantity, :rent, :recurrence, :option_id] e...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/commission_policy.rb
Ruby
mit
8,966
main
246
# frozen_string_literal: true class CommissionPolicy < ApplicationPolicy def update? (user.role_admin_for?(seller) || user.role_support_for?(seller)) && record.deposit_purchase.seller == seller end def complete? update? end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/direct_affiliate_policy.rb
Ruby
mit
8,966
main
481
# frozen_string_literal: true class DirectAffiliatePolicy < ApplicationPolicy def index? user.role_accountant_for?(seller) || user.role_admin_for?(seller) || user.role_marketing_for?(seller) || user.role_support_for?(seller) end def show? index? end def create? user.role_admin_for?(...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/asset_preview_policy.rb
Ruby
mit
8,966
main
233
# frozen_string_literal: true # Products > Edit product class AssetPreviewPolicy < ApplicationPolicy def create? user.role_admin_for?(seller) || user.role_marketing_for?(seller) end def destroy? create? end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/support_policy.rb
Ruby
mit
8,966
main
246
# frozen_string_literal: true class SupportPolicy < ApplicationPolicy def index? user.role_accountant_for?(seller) || user.role_admin_for?(seller) || user.role_marketing_for?(seller) || user.role_support_for?(seller) end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/seller_context.rb
Ruby
mit
8,966
main
427
# frozen_string_literal: true class SellerContext attr_reader :user, :seller # Special context when pundit_user is used in a context where the presenter works with user not being # authenticated. Usually, this is because the presenter is used for both public and seller areas. def self.logged_out new(user:...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/application_policy.rb
Ruby
mit
8,966
main
936
# frozen_string_literal: true class ApplicationPolicy attr_reader :user, :seller, :record class_attribute :allow_anonymous_user_access, default: false class << self def allow_anonymous_user_access! self.allow_anonymous_user_access = true end end def initialize(context, record) @context =...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/utm_link_policy.rb
Ruby
mit
8,966
main
554
# frozen_string_literal: true class UtmLinkPolicy < ApplicationPolicy def index? Feature.active?(:utm_links, seller) && (user.role_admin_for?(seller) || user.role_marketing_for?(seller) || user.role_support_for?(seller) || user.role_accountant_for?(seller)) end def create? Feature.active...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/user_policy.rb
Ruby
mit
8,966
main
359
# frozen_string_literal: true # Settings / Main class UserPolicy < ApplicationPolicy def deactivate? user.role_owner_for?(seller) end def generate_product_details_with_ai? seller.eligible_for_ai_product_generation? && (user.is_team_member? || user.id == seller.id || user.role_admin_for?(seller) || user....
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/gumroad_blog/posts_policy.rb
Ruby
mit
8,966
main
448
# frozen_string_literal: true class GumroadBlog::PostsPolicy < ApplicationPolicy allow_anonymous_user_access! def index? true end def show? return false unless record.alive? return false unless record.shown_on_profile? return false if record.workflow_id.present? return false unless record...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/checkout/upsell_policy.rb
Ruby
mit
8,966
main
611
# frozen_string_literal: true class Checkout::UpsellPolicy < ApplicationPolicy def index? user.role_accountant_for?(seller) || user.role_admin_for?(seller) || user.role_marketing_for?(seller) || user.role_support_for?(seller) end def paged? index? end def cart_item? index? end ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/checkout/offer_code_policy.rb
Ruby
mit
8,966
main
511
# frozen_string_literal: true class Checkout::OfferCodePolicy < ApplicationPolicy def index? user.role_accountant_for?(seller) || user.role_admin_for?(seller) || user.role_marketing_for?(seller) || user.role_support_for?(seller) end def paged? index? end def statistics? index? end...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/checkout/form_policy.rb
Ruby
mit
8,966
main
576
# frozen_string_literal: true class Checkout::FormPolicy < ApplicationPolicy def show? user.role_accountant_for?(seller) || user.role_admin_for?(seller) || user.role_marketing_for?(seller) || user.role_support_for?(seller) end def update? user.role_admin_for?(seller) || user.role_marketi...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/audience/purchase_policy.rb
Ruby
mit
8,966
main
844
# frozen_string_literal: true class Audience::PurchasePolicy < ApplicationPolicy def index? user.role_accountant_for?(seller) || user.role_admin_for?(seller) || user.role_marketing_for?(seller) || user.role_support_for?(seller) end def update? user.role_admin_for?(seller) || user.role_su...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/audience/follower_policy.rb
Ruby
mit
8,966
main
383
# frozen_string_literal: true class Audience::FollowerPolicy < ApplicationPolicy def index? user.role_accountant_for?(seller) || user.role_admin_for?(seller) || user.role_marketing_for?(seller) || user.role_support_for?(seller) end def update? user.role_admin_for?(seller) || user.role_su...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/admin/charges/charge_policy.rb
Ruby
mit
8,966
main
344
# frozen_string_literal: true class Admin::Charges::ChargePolicy < ApplicationPolicy def sync_status_with_charge_processor? record.purchases.where(purchase_state: %w(in_progress failed)).exists? end def refund? record.successful_purchases.non_free.not_fully_refunded.exists? end def refund_for_fraud...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/admin/products/staff_picked/link_policy.rb
Ruby
mit
8,966
main
288
# frozen_string_literal: true class Admin::Products::StaffPicked::LinkPolicy < ApplicationPolicy def create? return false if record.staff_picked_product&.not_deleted? record.recommendable? end def destroy? record.staff_picked_product&.not_deleted? || false end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/products/affiliated_policy.rb
Ruby
mit
8,966
main
259
# frozen_string_literal: true class Products::AffiliatedPolicy < ApplicationPolicy def index? user.role_accountant_for?(seller) || user.role_admin_for?(seller) || user.role_marketing_for?(seller) || user.role_support_for?(seller) end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/products/collabs_policy.rb
Ruby
mit
8,966
main
262
# frozen_string_literal: true class Products::CollabsPolicy < ApplicationPolicy def index? user.role_accountant_for?(seller) || user.role_admin_for?(seller) || user.role_marketing_for?(seller) || user.role_support_for?(seller) end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/products/archived/link_policy.rb
Ruby
mit
8,966
main
328
# frozen_string_literal: true class Products::Archived::LinkPolicy < ApplicationPolicy def index? Pundit.policy!(@context, Link).index? end def create? Pundit.policy!(@context, Link).new? && record.not_archived? end def destroy? Pundit.policy!(@context, Link).new? && record.archived? ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/products/variants/link_policy.rb
Ruby
mit
8,966
main
299
# frozen_string_literal: true # Products # Audience > Customers # class Products::Variants::LinkPolicy < ApplicationPolicy def index? user.role_accountant_for?(seller) || user.role_admin_for?(seller) || user.role_marketing_for?(seller) || user.role_support_for?(seller) end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/product_duplicates/link_policy.rb
Ruby
mit
8,966
main
236
# frozen_string_literal: true # Products section # class ProductDuplicates::LinkPolicy < ApplicationPolicy def create? user.role_admin_for?(seller) || user.role_marketing_for?(seller) end def show? create? end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/settings/profile_policy.rb
Ruby
mit
8,966
main
736
# frozen_string_literal: true class Settings::ProfilePolicy < ApplicationPolicy def show? user.role_accountant_for?(seller) || user.role_admin_for?(seller) || user.role_marketing_for?(seller) || user.role_support_for?(seller) end def update? user.role_admin_for?(seller) || user.role_mark...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/settings/main/user_policy.rb
Ruby
mit
8,966
main
298
# frozen_string_literal: true class Settings::Main::UserPolicy < ApplicationPolicy def show? user.role_admin_for?(seller) end def update? user.role_owner_for?(seller) end def resend_confirmation_email? update? end def invalidate_active_sessions? update? end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/settings/team/team_membership_policy.rb
Ruby
mit
8,966
main
247
# frozen_string_literal: true class Settings::Team::TeamMembershipPolicy < ApplicationPolicy def update? user.role_admin_for?(seller) end def destroy? update? || user == record.user end def restore? destroy? end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/settings/team/user_policy.rb
Ruby
mit
8,966
main
258
# frozen_string_literal: true class Settings::Team::UserPolicy < ApplicationPolicy def show? user.role_accountant_for?(seller) || user.role_admin_for?(seller) || user.role_marketing_for?(seller) || user.role_support_for?(seller) end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/settings/team/team_invitation_policy.rb
Ruby
mit
8,966
main
351
# frozen_string_literal: true class Settings::Team::TeamInvitationPolicy < ApplicationPolicy def create? user.role_admin_for?(seller) end def update? create? end def destroy? create? end def restore? destroy? end def accept? user.role_owner_for?(seller) end def resend_inv...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/settings/payments/user_policy.rb
Ruby
mit
8,966
main
614
# frozen_string_literal: true class Settings::Payments::UserPolicy < ApplicationPolicy def show? user.role_admin_for?(seller) end def update? user.role_owner_for?(seller) && record == seller end def set_country? update? end def opt_in_to_au_backtax_collection? update? end def veri...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/settings/authorized_applications/oauth_application_policy.rb
Ruby
mit
8,966
main
297
# frozen_string_literal: true class Settings::AuthorizedApplications::OauthApplicationPolicy < ApplicationPolicy def index? user.role_admin_for?(seller) end def create? index? end def edit? index? end def update? index? end def destroy? index? end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/settings/totp/user_policy.rb
Ruby
mit
8,966
main
261
# frozen_string_literal: true class Settings::Totp::UserPolicy < ApplicationPolicy def create? user.role_owner_for?(seller) end def confirm? create? end def destroy? create? end def regenerate_recovery_codes? create? end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/policies/settings/advanced/user_policy.rb
Ruby
mit
8,966
main
208
# frozen_string_literal: true class Settings::Advanced::UserPolicy < ApplicationPolicy def show? user.role_admin_for?(seller) end def update? show? end def test_ping? show? end end