[Xfce4-commits] <moka:master> Add mass mail for admins.

Nick Schermer noreply at xfce.org
Sun Nov 20 16:00:01 CET 2011


Updating branch refs/heads/master
         to 40fb5a9442213462c0d49e763468d73856b89a18 (commit)
       from 24edf0daf533a595a70a6206203a52a336e50180 (commit)

commit 40fb5a9442213462c0d49e763468d73856b89a18
Author: Nick Schermer <nick at xfce.org>
Date:   Sun Nov 20 15:58:10 2011 +0100

    Add mass mail for admins.

 examples/xfce/project_release_mail.erb |   11 ----------
 lib/controllers/maintainers.rb         |   34 ++++++++++++++++++++++++++-----
 lib/views/maintainer.haml              |   29 +++++++++++++++++++++++++++
 lib/views/project_release_update.haml  |    4 +-
 lib/views/stylesheet.sass              |    4 +-
 5 files changed, 61 insertions(+), 21 deletions(-)

diff --git a/examples/xfce/project_release_mail.erb b/examples/xfce/project_release_mail.erb
deleted file mode 100644
index e6a1d8d..0000000
--- a/examples/xfce/project_release_mail.erb
+++ /dev/null
@@ -1,11 +0,0 @@
-<%= release.project.name %> <%= release.version %> is now available for download as
-
-  <%= release.tarball_basename %>
-
-  SHA1 checksum: <%= release.checksum(Digest::SHA1) %>
-   MD5 checksum: <%= release.checksum(Digest::MD5) %>
-
-from the following mirrors:
-
-<%= release.download_url %>
-<%= message %>
diff --git a/lib/controllers/maintainers.rb b/lib/controllers/maintainers.rb
index a8e01bf..b3ec81d 100755
--- a/lib/controllers/maintainers.rb
+++ b/lib/controllers/maintainers.rb
@@ -4,22 +4,44 @@ module Moka
       include Moka::Models
 
       def self.registered(app)
-        app.get '/maintainer/:name' do
-          @maintainer = Maintainer.get(params[:name])
+        app.get '/maintainer' do
 
-          authentication_required(@maintainer)
+          authentication_required
 
-          view :maintainer_profile
+          view :maintainer
         end
 
-        app.get '/maintainer' do
+        app.post '/maintainer' do
 
           authentication_required
 
+          unless params[:from].empty? or params[:subject].empty? or params[:body].empty?
+            for maintainer in Maintainer.all(:active => true)
+              next if maintainer.email.empty?
+
+              body = params[:body]
+              body.gsub!('<realname>', maintainer.realname)
+              body.gsub!('<username>', maintainer.username)
+
+              Pony.mail :to => maintainer.email,
+                        :from => params[:from],
+                        :subject => params[:subject],
+                        :body => body
+            end
+          end
+
           view :maintainer
         end
 
-        app.post '/maintainer/:id' do
+        app.get '/maintainer/:name' do
+          @maintainer = Maintainer.get(params[:name])
+
+          authentication_required(@maintainer)
+
+          view :maintainer_profile
+        end
+
+        app.post '/maintainer/:username' do
           @maintainer = Maintainer.get(params[:username])
 
           authentication_required(@maintainer)
diff --git a/lib/views/maintainer.haml b/lib/views/maintainer.haml
index 0bc7583..e870c23 100644
--- a/lib/views/maintainer.haml
+++ b/lib/views/maintainer.haml
@@ -14,6 +14,35 @@
       %td #{maintainer.email}
 
 %h2 Active Maintainers
+%h3 Contact
+%form{:method => "post", :action => "/maintainer"}
+  %fieldset
+    %p
+      %label{:for => "from"} From:
+      %input{:type => "text",
+             :id => "from",
+             :name => "from",
+             :value => "#{authentication_user.email}"}
+    %p
+      %label{:for => "subject"} Subject:
+      %input{:type => "text",
+             :id => "subject",
+             :name => "subject",
+             :class => "fill"}
+    %p
+      %label{:for => "body"} Message:
+      %textarea{:name => "body",
+                :id => "body",
+                :wrap => "off"}
+    %p.quote.info
+      %strong <realname>
+      and
+      %strong <username>
+      are replaced in the message body.
+    %p.quote
+      %input{:type => "submit", :value => "Mail Active Maintainers"}
+
+%h3 Accounts
 %p
   Accounts of the maintainers that are currently using the release manager.
   %b Bold
diff --git a/lib/views/project_release_update.haml b/lib/views/project_release_update.haml
index d38fc47..02ac2da 100755
--- a/lib/views/project_release_update.haml
+++ b/lib/views/project_release_update.haml
@@ -1,6 +1,6 @@
 %h2 Tarball
-%fieldset
-  %form{:method => "post", :enctype => "multipart/form-data"}
+%form{:method => "post", :enctype => "multipart/form-data"}
+  %fieldset
     %p
       %label Filename: 
       %input{:type => "text", :readonly => true, :value => @release.tarball_basename, :size => 30}
diff --git a/lib/views/stylesheet.sass b/lib/views/stylesheet.sass
index 39a6d34..cf2dd9a 100755
--- a/lib/views/stylesheet.sass
+++ b/lib/views/stylesheet.sass
@@ -145,10 +145,10 @@ fieldset
 
   textarea
     width: 70%
-    height: 10em
+    height: 7em
 
   input.fill
-    width: 50%
+    width: 70%
 
   p.error, p.info
     padding-left: 1em


More information about the Xfce4-commits mailing list