made that stuff work
This commit is contained in:
parent
175e113af1
commit
09b6a6bc10
|
@ -2,6 +2,10 @@ class Inbox < ActiveRecord::Base
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :question
|
belongs_to :question
|
||||||
|
|
||||||
|
before_create do
|
||||||
|
raise "User does not want to receive anonymous questions" if self.question.author_is_anonymous and !self.user.privacy_allow_anonymous_questions?
|
||||||
|
end
|
||||||
|
|
||||||
def answer(answer_content, user)
|
def answer(answer_content, user)
|
||||||
answer = user.answer(self.question, answer_content)
|
answer = user.answer(self.question, answer_content)
|
||||||
self.destroy
|
self.destroy
|
||||||
|
|
|
@ -5,10 +5,6 @@ class Question < ActiveRecord::Base
|
||||||
|
|
||||||
validates :content, length: { maximum: 255 }
|
validates :content, length: { maximum: 255 }
|
||||||
|
|
||||||
before_create do
|
|
||||||
raise "User does not want to receive anonymous questions" if self.author_is_anonymous and !self.user.privacy_allow_anonymous_questions?
|
|
||||||
end
|
|
||||||
|
|
||||||
before_destroy do
|
before_destroy do
|
||||||
user.decrement! :asked_count unless self.author_is_anonymous
|
user.decrement! :asked_count unless self.author_is_anonymous
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,41 +6,47 @@
|
||||||
- else
|
- else
|
||||||
= @user.motivation_header
|
= @user.motivation_header
|
||||||
.panel-body
|
.panel-body
|
||||||
#question-box
|
- if user_signed_in? or @user.privacy_allow_anonymous_questions?
|
||||||
.row
|
#question-box
|
||||||
.col-xs-12
|
.row
|
||||||
%textarea.form-control{:name => "qb-question", :placeholder => "Type your question here…"}
|
.col-xs-12
|
||||||
.row{:style => "padding-top: 5px; padding-left: 5px; padding-right: 5px;"}
|
%textarea.form-control{:name => "qb-question", :placeholder => "Type your question here…"}
|
||||||
.col-xs-6
|
.row{:style => "padding-top: 5px; padding-left: 5px; padding-right: 5px;"}
|
||||||
- if user_signed_in? # and @user.allow_anonymous
|
.col-xs-6
|
||||||
%input{:name => "qb-anonymous", :type => "checkbox"}/
|
- if user_signed_in?
|
||||||
Hide your name
|
- if @user.privacy_allow_anonymous_questions?
|
||||||
%br/
|
%input{:name => "qb-anonymous", :type => "checkbox"}/
|
||||||
.col-xs-6
|
Hide your name
|
||||||
%p.pull-right
|
%br/
|
||||||
%input{name: 'qb-to', type: 'hidden', :value => @user.id}/
|
- else
|
||||||
%button.btn.btn-primary{name: 'qb-ask', :type => "button", data: {loading_text: 'Asking...', promote: user_signed_in? ? "false" : "true" }} Ask
|
%input{:name => "qb-anonymous", :type => "hidden", :value => "false"}/
|
||||||
|
.col-xs-6
|
||||||
|
%p.pull-right
|
||||||
|
%input{name: 'qb-to', type: 'hidden', :value => @user.id}/
|
||||||
|
%button.btn.btn-primary{name: 'qb-ask', :type => "button", data: {loading_text: 'Asking...', promote: user_signed_in? ? "false" : "true" }} Ask
|
||||||
- unless user_signed_in?
|
- unless user_signed_in?
|
||||||
#question-box-promote.row{:style => "display: none;"}
|
- if @user.privacy_allow_anonymous_questions?
|
||||||
.row
|
#question-box-promote.row{:style => "display: none;"}
|
||||||
.col-xs-12.text-center
|
.row
|
||||||
%strong Your question has been sent.
|
.col-xs-12.text-center
|
||||||
.row
|
%strong Your question has been sent.
|
||||||
.col-sm-1
|
.row
|
||||||
.col-sm-5
|
.col-sm-1
|
||||||
%button#create-account.btn.btn-block.btn-primary Create an account
|
.col-sm-5
|
||||||
.col-sm-5
|
%button#create-account.btn.btn-block.btn-primary Create an account
|
||||||
%button#new-question.btn.btn-block.btn-default Ask another question
|
.col-sm-5
|
||||||
.col-sm-1
|
%button#new-question.btn.btn-block.btn-default Ask another question
|
||||||
.row
|
.col-sm-1
|
||||||
.col-sm-1
|
.row
|
||||||
.col-xs-12.col-sm-10
|
.col-sm-1
|
||||||
%small
|
.col-xs-12.col-sm-10
|
||||||
Join
|
%small
|
||||||
= APP_CONFIG['site_name']
|
Join
|
||||||
today! You'll be able to follow and ask people you know and a lot more.
|
= APP_CONFIG['site_name']
|
||||||
.col-sm-1
|
today! You'll be able to follow and ask people you know and a lot more.
|
||||||
/ %p
|
.col-sm-1
|
||||||
/ This user does not want to get asked by strangers. Why don't you
|
- else
|
||||||
/ = succeed "?" do
|
%p
|
||||||
/ %a{:href => "{{ url_for('register') }}"} sign up
|
This user does not want to get asked by strangers. Why don't you
|
||||||
|
= succeed "?" do
|
||||||
|
%a{:href => "{{ url_for('register') }}"} sign up
|
Loading…
Reference in New Issue