allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject [09/50] [abbrv] allura git commit: [#6107] ticket:748 Added option for allowing email postings to ForgeBlog app
Date Wed, 27 May 2015 11:57:41 GMT
[#6107] ticket:748 Added option for allowing email postings to ForgeBlog app


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/1eb76e43
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/1eb76e43
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/1eb76e43

Branch: refs/heads/ib/7868
Commit: 1eb76e43aa60d76bc037d584f39e28cc2af4cc64
Parents: 1ebfe01
Author: Aleksey 'LXj' Alekseyev <gotletter@gmail.com>
Authored: Thu Apr 30 22:15:39 2015 +0300
Committer: Aleksey 'LXj' Alekseyev <gotletter@gmail.com>
Committed: Thu Apr 30 22:15:46 2015 +0300

----------------------------------------------------------------------
 ForgeBlog/forgeblog/main.py                        | 17 +++++++++++++++--
 ForgeBlog/forgeblog/model/blog.py                  | 10 +++++++---
 .../forgeblog/templates/blog/admin_options.html    |  8 ++++++++
 3 files changed, 30 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/1eb76e43/ForgeBlog/forgeblog/main.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index 160b94e..b4dcd4a 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -35,7 +35,7 @@ from webob import exc
 from ming.orm import session
 
 # Pyforge-specific imports
-from allura.app import Application, SitemapEntry
+from allura.app import Application, SitemapEntry, ConfigOption
 from allura.app import DefaultAdminController
 from allura.lib import helpers as h
 from allura.lib.search import search_app
@@ -90,6 +90,9 @@ class ForgeBlogApp(Application):
         'write': 'Create new blog entry.',
         'admin': 'Set permissions. Enable/disable commenting.',
     }
+    config_options = Application.config_options + [
+        ConfigOption('AllowEmailPosting', bool, True)
+    ]
     ordinal = 14
     exportable = True
     config_options = Application.config_options
@@ -144,6 +147,14 @@ class ForgeBlogApp(Application):
         else:
             return True
 
+    @property
+    def allow_email_posting(self):
+        return self.config.options.get('AllowEmailPosting', True)
+
+    @allow_email_posting.setter
+    def allow_email_posting(self, show):
+        self.config.options['AllowEmailPosting'] = bool(show)
+
     @h.exceptionless([], log)
     def sidebar_menu(self):
         base = c.app.url
@@ -404,9 +415,11 @@ class BlogAdminController(DefaultAdminController):
     @without_trailing_slash
     @expose()
     @require_post()
-    def set_options(self, show_discussion=False):
+    def set_options(self, show_discussion=False, allow_email_posting=False):
         self.app.config.options[
             'show_discussion'] = show_discussion and True or False
+        self.app.config.options[
+            'AllowEmailPosting'] = allow_email_posting and True or False
         flash('Blog options updated')
         redirect(h.really_unicode(c.project.url() + 'admin/tools')
                  .encode('utf-8'))

http://git-wip-us.apache.org/repos/asf/allura/blob/1eb76e43/ForgeBlog/forgeblog/model/blog.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/model/blog.py b/ForgeBlog/forgeblog/model/blog.py
index 835c5d2..5839d76 100644
--- a/ForgeBlog/forgeblog/model/blog.py
+++ b/ForgeBlog/forgeblog/model/blog.py
@@ -21,6 +21,7 @@ from datetime import datetime
 from random import randint
 
 from pylons import tmpl_context as c, app_globals as g
+from tg import config as tg_config
 from pymongo.errors import DuplicateKeyError
 
 from ming import schema
@@ -184,9 +185,12 @@ class BlogPost(M.VersionedArtifact, ActivityObject):
 
     @property
     def email_address(self):
-        domain = '.'.join(
-            reversed(self.app.url[1:-1].split('/'))).replace('_', '-')
-        return '%s@%s%s' % (self.title.replace('/', '.'), domain, config.common_suffix)
+        if self.config.options.get('AllowEmailPosting', True):
+            domain = '.'.join(
+                reversed(self.app.url[1:-1].split('/'))).replace('_', '-')
+            return '%s@%s%s' % (self.title.replace('/', '.'), domain, config.common_suffix)
+        else:
+            return tg_config.get('forgemail.return_path')
 
     @staticmethod
     def make_base_slug(title, timestamp):

http://git-wip-us.apache.org/repos/asf/allura/blob/1eb76e43/ForgeBlog/forgeblog/templates/blog/admin_options.html
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/templates/blog/admin_options.html b/ForgeBlog/forgeblog/templates/blog/admin_options.html
index 8c549a0..586f099 100644
--- a/ForgeBlog/forgeblog/templates/blog/admin_options.html
+++ b/ForgeBlog/forgeblog/templates/blog/admin_options.html
@@ -26,6 +26,14 @@
         <span>{{app.show_discussion}}</span>
       {% endif %}
     </div>
+    <label class="grid-7">Allow posting replies via email:</label>
+    <div class="grid-6">
+      {% if allow_config %}
+        <input type="checkbox" name="allow_email_posting" id="allow_email_posting"{% if
app.allow_email_posting %} checked="checked"{% endif %}/>
+      {% else %}
+        <span>{{app.allow_email_posting}}</span>
+      {% endif %}
+    </div>
     <div class="grid-13">&nbsp;</div>
     <hr/>
     <div class="grid-13">&nbsp;</div>


Mime
View raw message