Add setting for monthly total and other minor improvements
This commit is contained in:
parent
a3636a5038
commit
ae793ad247
|
@ -105,6 +105,10 @@ module DiscourseDonations
|
||||||
args = user_params.to_h.slice(:email, :username, :password, :name).merge(rewards: output['rewards'])
|
args = user_params.to_h.slice(:email, :username, :password, :name).merge(rewards: output['rewards'])
|
||||||
Jobs.enqueue(:donation_user, args)
|
Jobs.enqueue(:donation_user, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if SiteSetting.discourse_donations_cause_category
|
||||||
|
Jobs.enqueue(:update_category_donation_statistics)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
render json: output
|
render json: output
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module Jobs
|
module Jobs
|
||||||
class UpdateCategoryDonationStatistics < ::Jobs::Scheduled
|
class UpdateCategoryDonationStatistics < ::Jobs::Scheduled
|
||||||
every 1.hour
|
every 1.day
|
||||||
|
|
||||||
def execute(args)
|
def execute(args)
|
||||||
return unless SiteSetting.discourse_donations_cause_category
|
return unless SiteSetting.discourse_donations_cause_category
|
||||||
|
|
|
@ -30,10 +30,13 @@ createWidget('category-header-widget', {
|
||||||
];
|
];
|
||||||
|
|
||||||
let metadata = [
|
let metadata = [
|
||||||
donationDisplay(category.donations_total || 0, 'total'),
|
donationDisplay(category.donations_total || 0, 'total')
|
||||||
donationDisplay(category.donations_month || 0, 'month')
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (Discourse.SiteSettings.discourse_donations_cause_month) {
|
||||||
|
metadata.push(donationDisplay(category.donations_month || 0, 'month'));
|
||||||
|
}
|
||||||
|
|
||||||
if (category.donations_github) {
|
if (category.donations_github) {
|
||||||
metadata.push(
|
metadata.push(
|
||||||
h('div.donations-github', this.attach('link', {
|
h('div.donations-github', this.attach('link', {
|
||||||
|
|
|
@ -22,6 +22,7 @@ en:
|
||||||
discourse_donations_causes_categories: "Categories of cause a user can donate do."
|
discourse_donations_causes_categories: "Categories of cause a user can donate do."
|
||||||
discourse_donations_cause_category: "Category causes enabled."
|
discourse_donations_cause_category: "Category causes enabled."
|
||||||
discourse_donations_cause_required: "Require user to select a cause when donating."
|
discourse_donations_cause_required: "Require user to select a cause when donating."
|
||||||
|
discourse_donations_cause_month: "Show monthly total of donations to each cause."
|
||||||
errors:
|
errors:
|
||||||
discourse_donations_amount_must_be_number: "Amounts must be numbers"
|
discourse_donations_amount_must_be_number: "Amounts must be numbers"
|
||||||
|
|
||||||
|
|
|
@ -73,3 +73,6 @@ plugins:
|
||||||
discourse_donations_cause_required:
|
discourse_donations_cause_required:
|
||||||
client: true
|
client: true
|
||||||
default: false
|
default: false
|
||||||
|
discourse_donations_cause_month:
|
||||||
|
client: true
|
||||||
|
default: false
|
||||||
|
|
|
@ -97,6 +97,7 @@ after_initialize do
|
||||||
add_to_serializer(:basic_category, :donations_cause) { object.donations_cause }
|
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_total) { object.donations_total }
|
||||||
add_to_serializer(:basic_category, :donations_month) { object.donations_month }
|
add_to_serializer(:basic_category, :donations_month) { object.donations_month }
|
||||||
|
add_to_serializer(:basic_category, :include_donations_month?) { SiteSetting.discourse_donations_cause_month }
|
||||||
add_to_serializer(:basic_category, :donations_backers) {
|
add_to_serializer(:basic_category, :donations_backers) {
|
||||||
ActiveModel::ArraySerializer.new(object.donations_backers, each_serializer: BasicUserSerializer).as_json
|
ActiveModel::ArraySerializer.new(object.donations_backers, each_serializer: BasicUserSerializer).as_json
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue