filter_parameter_logging :password, :pass_crypt, :pass_crypt_confirmation
- cache_sweeper :user_sweeper, :only => [:account, :hide, :unhide, :delete]
+ cache_sweeper :user_sweeper, :only => [:account, :set_status, :delete]
+ def terms
+ @title = t 'user.new.title'
+ @user = User.new(params[:user])
+
+ @legale = params[:legale] || OSM.IPToCountry(request.remote_ip) || APP_CONFIG['default_legale']
+ @text = OSM.legal_text_for_country(@legale)
+
+ if request.xhr?
+ render :update do |page|
+ page.replace_html "contributorTerms", :partial => "terms"
+ end
+ elsif @user.invalid?
+ render :action => 'new'
+ end
+ end
+
def save
@title = t 'user.new.title'
# Quova authentication details
#quova_username: ""
#quova_password: ""
+ # Spam threshold
+ spam_threshold: 50
+ # Default legale (jurisdiction location) for contributor terms
+ default_legale: GB
development:
<<: *standard_settings
return "#{tilesql} AND #{prefix}latitude BETWEEN #{minlat} AND #{maxlat} AND #{prefix}longitude BETWEEN #{minlon} AND #{maxlon}"
end
-
+ # Return a spam score for a chunk of text
+ def self.spam_score(text)
+ link_count = 0
+ link_size = 0
+
+ doc = Nokogiri::HTML(text)
+
+ if doc.content.length > 0
+ doc.xpath("//a").each do |link|
+ link_count += 1
+ link_size += link.content.length
+ end
+
+ link_proportion = link_size.to_f / doc.content.length.to_f
+ else
+ link_proportion = 0
+ end
+
+ return [link_proportion - 0.2, 0.0].max * 200 + link_count * 20
+ end
++
+ def self.legal_text_for_country(country_code)
+ file_name = File.join(RAILS_ROOT, "config", "legales", country_code.to_s + ".yml")
+ file_name = File.join(RAILS_ROOT, "config", "legales", APP_CONFIG['default_legale'] + ".yml") unless File.exist? file_name
+ YAML::load_file(file_name)
+ end
end
color: gray;
}
+ /* Rules for the user list */
+
+ #user_list {
+ width: 100%;
+ font-size: small;
+ }
+
+ #user_list tr {
+ vertical-align: center;
+ }
+
+ #user_list p {
+ margin-top: 0px;
+ margin-bottom: 0px;
+ }
+
+ #user_list_actions {
+ float: right;
+ margin-top: 10px;
+ }
+
+/* Rules for the account confirmation page */
+
+div#contributorTerms {
+ border: 1px solid black;
+ padding: 4px;
+ overflow: auto;
+ width: 80%;
+ height: 60%;
+}
+
+div#contributorTerms p#first {
+ margin-top: 0px;
+}
+
+div#contributorTerms p#last {
+ margin-bottom: 0px;
+}
+
+div#contributorTerms ol {
+ margin-bottom: 0px;
+}
+
+div#contributorTerms img {
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+ margin-top: 10%;
+}
+
+form#termsForm {
+ width: 80%;
+}
+
+form#termsForm div#buttons {
+ float: right;
+}
+
+form#termsForm input#agree {
+ margin-left: 50px;
+}
+
/* Rules for the account settings page */
#accountForm td {