Merge pull request #1034 from indentlabs/oct-2021-release

Oct 2021 release
This commit is contained in:
Andrew Brown 2021-09-30 23:38:03 -07:00 committed by GitHub
commit e2dc0e07dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 44 additions and 4 deletions

View File

@ -12,6 +12,10 @@ class DocumentsController < ApplicationController
before_action :set_navbar_actions, except: [:edit, :plaintext]
before_action :set_footer_visibility, only: [:edit]
# Skip UI-heavy calls for API endpoints
skip_before_action :cache_most_used_page_information, only: [:update]
skip_before_action :cache_forums_unread_counts, only: [:update]
# TODO: verify_user_can_read, verify_user_can_edit, etc before_actions instead of inlining them
before_action :cache_linkable_content_for_each_content_type, only: [:edit]

View File

@ -17,7 +17,14 @@ module HasImageUploads
end
def random_image_including_private(format: :medium)
image_uploads.sample.try(:src, format).presence || "card-headers/#{self.class.name.downcase.pluralize}.jpg"
@random_image_including_private_cache ||= {}
key = self.class.name + self.id.to_s
return @random_image_including_private_cache[key] if @random_image_including_private_cache.key?(key)
result = image_uploads.sample.try(:src, format).presence || "card-headers/#{self.class.name.downcase.pluralize}.jpg"
@random_image_including_private_cache[key] = result
result
end
def first_public_image(format: :medium)

View File

@ -20,7 +20,7 @@ class Creature < ApplicationRecord
include Serendipitous::Concern
include Authority::Abilities
self.authorizer_name = 'ExtendedContentAuthorizer'
self.authorizer_name = 'CoreContentAuthorizer'
# Locations
relates :habitats, with: :wildlifeships

View File

@ -186,8 +186,10 @@
<% end %>
<div class="grey-text uppercase center">Create something new</div>
<% shown_creatures = false %>
<% @activated_content_types.sample(3).each do |type| %>
<% klass = content_class_from_name(type) %>
<% shown_creatures = true if type == 'Creature' %>
<div>
<%= link_to send("new_#{type.downcase}_path"), class: "white-text", style: 'width: 100%' do %>
<div class="hoverable card-panel <%= klass.color %>" style="margin-bottom: 4px">
@ -209,6 +211,24 @@
<% end %>
</div>
<% end %>
<br />
<div>
<%= link_to new_creature_path, class: "white-text", style: 'width: 100%' do %>
<div class="hoverable card-panel <%= Creature.color %>" style="margin-bottom: 4px">
<div class="valign-wrapper">
<i class="material-icons grey-bordered-text" class="left" style="font-size: 3em;"><%= Creature.icon %></i>
<span style="font-size: 1.1em; margin-left: 1em">
New Creature<br />
<small>
Free for all users in October
</small>
</span>
</div>
</div>
<% end %>
</div>
</div>
</div>

View File

@ -66,7 +66,7 @@ Rails.application.config.content_types = {
# Content types to label as "new" around the site
new: [
Lore
]
}

View File

@ -6,7 +6,7 @@ Rails.application.config.promos[:promo_bogo] = {}
Rails.application.config.promos[:promo_bogo][:start_date] = 'March 21, 2020'.to_date
Rails.application.config.promos[:promo_bogo][:end_date] = Rails.application.config.promos[:promo_bogo][:start_date] + 2.weeks
# Lore free during the month of April
# Lore free during the month of April, 2020
# Need to change Lore.rb authorizer at the end lol
if Date.current >= 'March 1, 2020'.to_date
if Date.current < 'April 1, 2020'.to_date
@ -14,3 +14,12 @@ if Date.current >= 'March 1, 2020'.to_date
Rails.application.config.content_types[:premium] -= [Lore]
end
end
# Lore free during the month of October
# Need to change Creature.rb authorizer at the end
if Date.current >= 'October 1, 2021'.to_date
if Date.current < 'November 1, 2021'.to_date
Rails.application.config.content_types[:free] << Creature
Rails.application.config.content_types[:premium] -= [Creature]
end
end