only show cause UI in cause categories

This commit is contained in:
Angus McLeod 2018-09-22 17:09:06 +10:00
parent 45ece34200
commit d58c04a592
3 changed files with 6 additions and 3 deletions

View File

@ -13,13 +13,12 @@ createWidget('category-header-widget', {
tagName: 'span',
html() {
const path = window.location.pathname;
let category;
const controller = this.container.lookup('controller:navigation/category');
category = controller.get("category");
if(/^\/c\//.test(path)) {
if(category && category.donations_cause) {
$("body").addClass("donations-category");
let contents = [

View File

@ -151,7 +151,6 @@ div.stripe-errors {
width: 500px;
margin: 0 auto;
font-size: 1.2rem;
padding-top: 10px;
padding-bottom: 40px;
display: flex;
align-items: center;

View File

@ -36,6 +36,10 @@ after_initialize do
end
class ::Category
def donations_cause
SiteSetting.discourse_donations_causes_categories.split('|').include? self.id.to_s
end
def donations_total
if custom_fields['donations_total']
custom_fields['donations_total']
@ -82,6 +86,7 @@ after_initialize do
end
if SiteSetting.discourse_donations_cause_category
add_to_serializer(:basic_category, :donations_cause) { object.donations_cause }
add_to_serializer(:basic_category, :donations_total) { object.donations_total }
add_to_serializer(:basic_category, :donations_month) { object.donations_month }
add_to_serializer(:basic_category, :donations_backers) {