mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Read Faq badge
This commit is contained in:
parent
167a2a68e6
commit
833c50c460
22
app/assets/javascripts/discourse/views/static.js.es6
Normal file
22
app/assets/javascripts/discourse/views/static.js.es6
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
export default Discourse.View.extend({
|
||||||
|
didInsertElement: function() {
|
||||||
|
var path = this.get('controller.model.path');
|
||||||
|
if(path === "faq" || path === "guidelines"){
|
||||||
|
var $window = $(window);
|
||||||
|
$window.on('scroll.faq', function(){
|
||||||
|
if($window.scrollTop() + $window.height() > $(document).height() - 10) {
|
||||||
|
if(!this._notifiedBottom){
|
||||||
|
this._notifiedBottom = true;
|
||||||
|
Discourse.ajax("/users/read-faq", {
|
||||||
|
method: "POST"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
willDestroyElement: function(){
|
||||||
|
$(window).off('scroll.faq');
|
||||||
|
}
|
||||||
|
});
|
@ -411,6 +411,15 @@ class UsersController < ApplicationController
|
|||||||
render json: success_json
|
render json: success_json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def read_faq
|
||||||
|
if(user = current_user)
|
||||||
|
user.user_stat.read_faq = 1.second.ago
|
||||||
|
user.user_stat.save
|
||||||
|
end
|
||||||
|
|
||||||
|
render json: success_json
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def honeypot_value
|
def honeypot_value
|
||||||
|
@ -12,12 +12,19 @@ class Badge < ActiveRecord::Base
|
|||||||
FirstFlag = 13
|
FirstFlag = 13
|
||||||
FirstLink = 14
|
FirstLink = 14
|
||||||
FirstQuote = 15
|
FirstQuote = 15
|
||||||
|
ReadFaq = 16
|
||||||
|
|
||||||
# other consts
|
# other consts
|
||||||
AutobiographerMinBioLength = 10
|
AutobiographerMinBioLength = 10
|
||||||
|
|
||||||
|
|
||||||
module Queries
|
module Queries
|
||||||
|
|
||||||
|
ReadFaq = <<SQL
|
||||||
|
SELECT user_id, read_faq
|
||||||
|
WHERE read_faq IS NOT NULL
|
||||||
|
SQL
|
||||||
|
|
||||||
FirstQuote = <<SQL
|
FirstQuote = <<SQL
|
||||||
SELECT l.user_id, l.post_id, l.created_at granted_at
|
SELECT l.user_id, l.post_id, l.created_at granted_at
|
||||||
FROM
|
FROM
|
||||||
|
@ -1996,3 +1996,6 @@ en:
|
|||||||
first_quote:
|
first_quote:
|
||||||
name: First Quote
|
name: First Quote
|
||||||
description: Quoted a user
|
description: Quoted a user
|
||||||
|
read_faq:
|
||||||
|
name: Read Faq
|
||||||
|
description: Read the community guidelines
|
||||||
|
@ -181,6 +181,7 @@ Discourse::Application.routes.draw do
|
|||||||
get "privacy" => "static#show", id: "privacy"
|
get "privacy" => "static#show", id: "privacy"
|
||||||
get "signup" => "list#latest"
|
get "signup" => "list#latest"
|
||||||
|
|
||||||
|
post "users/read-faq" => "users#read_faq"
|
||||||
get "users/search/users" => "users#search_users"
|
get "users/search/users" => "users#search_users"
|
||||||
get "users/password-reset/:token" => "users#password_reset"
|
get "users/password-reset/:token" => "users#password_reset"
|
||||||
put "users/password-reset/:token" => "users#password_reset"
|
put "users/password-reset/:token" => "users#password_reset"
|
||||||
|
@ -18,6 +18,15 @@ trust_level_badges.each do |spec|
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Badge.seed do |b|
|
||||||
|
b.id = Badge::ReadFaq
|
||||||
|
b.name = "Read Faq"
|
||||||
|
b.badge_type_id = BadgeType::Bronze
|
||||||
|
b.multiple_grant = false
|
||||||
|
b.target_posts = false
|
||||||
|
b.query = Badge::Queries::ReadFaq
|
||||||
|
end
|
||||||
|
|
||||||
Badge.seed do |b|
|
Badge.seed do |b|
|
||||||
b.id = Badge::FirstLink
|
b.id = Badge::FirstLink
|
||||||
b.name = "First Link"
|
b.name = "First Link"
|
||||||
|
5
db/migrate/20140711063215_add_read_faq_to_user_stats.rb
Normal file
5
db/migrate/20140711063215_add_read_faq_to_user_stats.rb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class AddReadFaqToUserStats < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :user_stats, :read_faq, :datetime
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user