Skip to content

Commit

Permalink
Merge branch 'origin/edge' into edge
Browse files Browse the repository at this point in the history
  • Loading branch information
drapetomaniac committed Nov 12, 2008
2 parents 2f2768b + 2c8d326 commit dac401c
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 5 deletions.
5 changes: 5 additions & 0 deletions app/controllers/people_controller.rb
Expand Up @@ -47,6 +47,10 @@ def create
@person.save
if @person.errors.empty?
session[:verified_identity_url] = nil
if global_prefs.can_send_email? && global_prefs.registration_notification?
admin = Person.find_first_admin
PersonMailer.deliver_registration_notification(admin,@person)
end
if global_prefs.email_verifications?
@person.email_verifications.create
flash[:notice] = %(Thanks for signing up! Check your email
Expand Down Expand Up @@ -111,6 +115,7 @@ def update
flash[:success] = 'Profile updated!'
format.html { redirect_to(@person) }
else
@all_categories = Category.find(:all, :order => "parent_id, name")
if preview?
@preview = @person.description = params[:person][:description]
end
Expand Down
11 changes: 11 additions & 0 deletions app/models/person.rb
Expand Up @@ -117,6 +117,7 @@ class Person < ActiveRecord::Base

before_create :create_blog, :check_config_for_deactivation
after_create :create_account
after_create :create_address
before_save :encrypt_password
before_validation :prepare_email, :handle_nil_description
#after_create :connect_to_admin
Expand Down Expand Up @@ -243,6 +244,16 @@ def formatted_categories
categories.collect { |cat| cat.long_name + "<br>"}.to_s.chop.chop.chop.chop
end

def create_address
address = Address.new( :name => 'personal' )
address.person = self
address.save
end

def address
addresses.first
end

## Account helpers

def create_account
Expand Down
8 changes: 8 additions & 0 deletions app/models/person_mailer.rb
Expand Up @@ -62,6 +62,14 @@ def email_verification(ev)
body "server_name" => server,
"code" => ev.code
end

def registration_notification(admin, new_peep)
from "Registration notification <registration@#{domain}>"
recipients admin.email
subject formatted_subject("New registration")
body "domain" => server,
"url" => person_path(new_peep)
end

private

Expand Down
2 changes: 1 addition & 1 deletion app/models/preference.rb
Expand Up @@ -21,7 +21,7 @@ class Preference < ActiveRecord::Base
attr_accessible :app_name, :server_name, :domain, :smtp_server,
:exception_notification,
:email_notifications, :email_verifications, :analytics,
:about, :demo, :whitelist, :gmail
:about, :demo, :whitelist, :gmail, :registration_notification

validates_presence_of :domain, :if => :using_email?
validates_presence_of :smtp_server, :if => :using_email?
Expand Down
9 changes: 9 additions & 0 deletions app/views/admin/preferences/edit.html.erb
Expand Up @@ -73,6 +73,15 @@

<br />

<p>Notify first admin for registrations</p>
<div class="form_row">
<label for="registration_notification"
class="checkbox">Registration Notification</label>
<%= f.check_box :registration_notification %>
</div>

<br />

<div class="form_row">
<label for="about">About</label>
<br />
Expand Down
5 changes: 5 additions & 0 deletions app/views/admin/preferences/show.html.erb
Expand Up @@ -40,6 +40,11 @@
<%=h @preferences.email_verifications %>
</p>

<p>
<b>Notify first admin of registrations:</b>
<%=h @preferences.registration_notification %>
</p>

<p>
<b>Demo site:</b>
<%=h @preferences.demo %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/broadcast_mailer/spew.erb
@@ -1,3 +1,3 @@
Hi <%= @person.name %><br><br>
<%= simple_format_without_paragraph @message %><br><br>
<%= @message %><br><br>
<%= @preferences_note %>
4 changes: 4 additions & 0 deletions app/views/categories/_providers.html.erb
@@ -1,4 +1,8 @@
<h2>Providers</h2>
<ul class="list activity small">
<%- if category.people.empty? -%>
<h3 class="blankstate">No providers (yet!)</h3>
<%- else -%>
<%= render :partial => 'person', :collection => category.people %>
<%- end -%>
</ul>
8 changes: 7 additions & 1 deletion app/views/categories/show.html.erb
@@ -1,14 +1,20 @@
<%- column_div :type => :primary do -%>
<h2><%=h @category.long_name %></h2>
<%- if @reqs.empty? -%>
<h3 class="blankstate">No reqs (yet!)</h3>
<%- else -%>
<h3>Requests</h3>
<ul class="list full">
<%= render :partial => 'reqs/req', :collection => @reqs %>
</ul>
<%- end -%>
<%- if admin? -%>
<%= link_to 'Edit', edit_category_path(@category) if 0 == @reqs.size %>
<%- end -%>
<%- end -%>
<%- column_div :type => :secondary do -%>
<%= render :partial => 'providers', :locals => { :category => @category } %>
<%= render :partial => 'providers', :locals => { :category => @category } %>
<%- end -%>
4 changes: 2 additions & 2 deletions app/views/messages/_full_message.html.erb
Expand Up @@ -6,7 +6,7 @@
<%= image_link full_message.sender, :class => "photo",
:image => :thumbnail %>
</div>
<%= display full_message.content %>
<%= display simple_format_without_paragraph full_message.content %>
<p class="meta tools">
Sent <%= time_ago_in_words full_message.created_at %> ago |
<%= link_to "Reply", reply_message_path(full_message) %> |
Expand All @@ -17,4 +17,4 @@
:method => :put %>
<% end -%>
</p>
</li>
</li>
4 changes: 4 additions & 0 deletions app/views/person_mailer/registration_notification.html.erb
@@ -0,0 +1,4 @@
A new person has registered:

http://<%= @domain %><%= @url %>

@@ -0,0 +1,9 @@
class AddRegistrationNotificationPreferences < ActiveRecord::Migration
def self.up
add_column :preferences, :registration_notification, :boolean, :default => false
end

def self.down
remove_column :preferences, :registration_notification
end
end

0 comments on commit dac401c

Please sign in to comment.