You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2018/12/21 17:15:30 UTC

[01/11] allura git commit: [#5461] posting (or creating) a ForumThread now subscribes you to it, same as posting already did for other things

Repository: allura
Updated Branches:
  refs/heads/db/5461 [created] d69e4176a


[#5461] posting (or creating) a ForumThread now subscribes you to it, same as posting already did for other things


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

Branch: refs/heads/db/5461
Commit: a94c28ba95b6d5faa54de9f45e6282da2f8c2ed5
Parents: c680776
Author: Dave Brondsema <da...@brondsema.net>
Authored: Tue Dec 18 11:40:33 2018 -0500
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Tue Dec 18 11:41:24 2018 -0500

----------------------------------------------------------------------
 Allura/allura/model/discuss.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/a94c28ba/Allura/allura/model/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index c7fcc27..240f2eb 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -306,8 +306,7 @@ class Thread(Artifact, ActivityObject):
              is_meta=False, **kw):
         if not ignore_security:
             require_access(self, 'post')
-        if self.ref_id and self.artifact:
-            self.artifact.subscribe()
+        self.primary().subscribe()
         if message_id is None:
             message_id = h.gen_message_id()
         parent = parent_id and self.post_class().query.get(_id=parent_id)


[07/11] allura git commit: [#5461] add subscribe option to new merge requests

Posted by br...@apache.org.
[#5461] add subscribe option to new merge requests


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

Branch: refs/heads/db/5461
Commit: 517072163092a485cf351ee758fe4a24b630f936
Parents: 67fde47
Author: Dave Brondsema <da...@brondsema.net>
Authored: Wed Dec 19 18:10:43 2018 -0500
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Thu Dec 20 11:59:01 2018 -0500

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py |  7 ++++---
 Allura/allura/lib/widgets/repo.py       | 10 ++++++++++
 Allura/allura/model/repository.py       |  4 ++++
 3 files changed, 18 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/51707216/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index ce7faa7..db5f9a4 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -45,7 +45,7 @@ from allura.lib.diff import HtmlSideBySideDiff
 from allura.lib.security import require_access, require_authenticated, has_access
 from allura.lib.widgets import form_fields as ffw
 from allura.lib.widgets.repo import SCMLogWidget, SCMRevisionWidget, SCMTreeWidget
-from allura.lib.widgets.repo import SCMMergeRequestWidget
+from allura.lib.widgets.repo import SCMMergeRequestWidget, SCMMergeRequestWidgetNew
 from allura.lib.widgets.repo import SCMMergeRequestDisposeWidget, SCMCommitBrowserWidget
 from allura.lib.widgets.subscriptions import SubscribeForm
 from allura.controllers import AppDiscussionController
@@ -162,7 +162,7 @@ class RepoRootController(BaseController, FeedController):
             target_branches = [
                 b.name
                 for b in c.app.repo.get_branches() + c.app.repo.get_tags()]
-        return SCMMergeRequestWidget(
+        return SCMMergeRequestWidgetNew(
             source_branches=source_branches,
             target_branches=target_branches)
 
@@ -197,7 +197,8 @@ class RepoRootController(BaseController, FeedController):
                 source_branch=kw['source_branch'],
                 summary=kw['summary'],
                 description=kw['description'])
-            mr.subscribe(user=c.user)
+            if kw.get('subscribe'):
+                mr.subscribe(user=c.user)
             M.Notification.post(
                 mr, 'merge_request',
                 subject=mr.email_subject,

http://git-wip-us.apache.org/repos/asf/allura/blob/51707216/Allura/allura/lib/widgets/repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/repo.py b/Allura/allura/lib/widgets/repo.py
index d00640d..3a9e7d9 100644
--- a/Allura/allura/lib/widgets/repo.py
+++ b/Allura/allura/lib/widgets/repo.py
@@ -82,6 +82,16 @@ class SCMMergeRequestWidget(ff.ForgeForm):
         return result
 
 
+class SCMMergeRequestWidgetNew(SCMMergeRequestWidget):
+
+    @property
+    def buttons(self):
+        # add to after the default submit button
+        return ew_core.NameList([
+            ew.Checkbox(name='subscribe', label='Subscribe to this merge request', value=True),
+        ])
+
+
 class SCMMergeRequestDisposeWidget(ff.ForgeForm):
 
     class fields(ew_core.NameList):

http://git-wip-us.apache.org/repos/asf/allura/blob/51707216/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index cff76e3..f68580e 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -818,6 +818,10 @@ class MergeRequest(VersionedArtifact, ActivityObject):
         return 'merge request #%s' % self.request_number
 
     @property
+    def type_name(self):
+        return 'merge request'
+
+    @property
     def activity_extras(self):
         d = ActivityObject.activity_extras.fget(self)
         d.update(summary=self.summary)


[11/11] allura git commit: [#5461] subscribe/cancel styling

Posted by br...@apache.org.
[#5461] subscribe/cancel styling


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

Branch: refs/heads/db/5461
Commit: d69e4176af67b44012bd915de2bd625e3ec664d5
Parents: ce7f141
Author: Dave Brondsema <da...@brondsema.net>
Authored: Fri Dec 21 12:07:34 2018 -0500
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Fri Dec 21 12:07:41 2018 -0500

----------------------------------------------------------------------
 Allura/allura/lib/widgets/repo.py                |  3 ++-
 Allura/allura/nf/allura/css/site_style.css       | 19 +++++++++++++++++++
 Allura/allura/templates/widgets/edit_post.html   |  2 +-
 .../allura/templates/widgets/new_topic_post.html |  2 +-
 .../templates/blog_widgets/post_form.html        |  2 +-
 .../templates/tracker_widgets/ticket_form.html   |  2 +-
 .../forgewiki/templates/wiki/page_edit.html      |  2 +-
 7 files changed, 26 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/d69e4176/Allura/allura/lib/widgets/repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/repo.py b/Allura/allura/lib/widgets/repo.py
index 60d358f..d73ef0c 100644
--- a/Allura/allura/lib/widgets/repo.py
+++ b/Allura/allura/lib/widgets/repo.py
@@ -87,7 +87,8 @@ class SCMMergeRequestWidget(ff.ForgeForm):
         # add things after the default submit button
         fields = ew_core.NameList()
         if self.show_subscribe_checkbox:
-            fields.append(ew.Checkbox(name='subscribe', label='Subscribe to this merge request', value=True))
+            fields.append(ew.Checkbox(name='subscribe', label='Subscribe to this merge request', value=True,
+                                      attrs={'class': 'subscribe-checkbox'}))
         return fields
 
 

http://git-wip-us.apache.org/repos/asf/allura/blob/d69e4176/Allura/allura/nf/allura/css/site_style.css
----------------------------------------------------------------------
diff --git a/Allura/allura/nf/allura/css/site_style.css b/Allura/allura/nf/allura/css/site_style.css
index 6c7db3b..ae910c0 100644
--- a/Allura/allura/nf/allura/css/site_style.css
+++ b/Allura/allura/nf/allura/css/site_style.css
@@ -2630,6 +2630,21 @@ div.attachment_item{
 .edit_post_form.reply .arw {
   display: none;
 }
+.edit_markdown_form .btn.link.attachment_form_add_button {
+    margin: 0 0 5px 5px;
+}
+.subscribe-checkbox {
+    margin-top: 7px;
+}
+.pad .editbox label.subscribe {
+    font-weight: normal;  /* override .pad .editbox label */
+}
+.btn.link.cancel_edit_post,
+.btn.link.cancel_form
+{
+    float:right;
+    margin-right: 35px;
+}
 
 #create_new_topic select {
   width: auto;
@@ -2919,6 +2934,10 @@ h1.title .viewer:hover {
 #forge_wiki_browse tr.deleted a {
   color: red;
 }
+#page_edit_form input[value=Cancel] {
+    float: right;
+    margin-right: 40px;
+}
 
 .scm-branch-label, .scm-tag-label {
   -moz-border-radius: 4px;

http://git-wip-us.apache.org/repos/asf/allura/blob/d69e4176/Allura/allura/templates/widgets/edit_post.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/edit_post.html b/Allura/allura/templates/widgets/edit_post.html
index 49a8242..6f0de46 100644
--- a/Allura/allura/templates/widgets/edit_post.html
+++ b/Allura/allura/templates/widgets/edit_post.html
@@ -34,7 +34,7 @@
     <input type="submit" value="{{submit_text}}" />
     {% if primary_artifact and c.user and c.user != c.user.anonymous() and not primary_artifact.subscribed() %}
       <label class="subscribe">
-        <input type="checkbox" checked name="subscribe">Subscribe to this {{ primary_artifact.type_name }}
+        <input type="checkbox" checked name="subscribe" class="subscribe-checkbox">Subscribe to this {{ primary_artifact.type_name }}
       </label>
     {% endif %}
     <a href="#" class="ui-button btn link cancel_edit_post">Cancel</a>

http://git-wip-us.apache.org/repos/asf/allura/blob/d69e4176/Allura/allura/templates/widgets/new_topic_post.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/new_topic_post.html b/Allura/allura/templates/widgets/new_topic_post.html
index 8910187..e62249e 100644
--- a/Allura/allura/templates/widgets/new_topic_post.html
+++ b/Allura/allura/templates/widgets/new_topic_post.html
@@ -52,7 +52,7 @@
       {% if c.user and c.user != c.user.anonymous() and not (subscribed or subscribed_to_tool) %}
         {# subscribed is per-forum and won't change if they change the forum dropdown value, but better than nothing? :( #}
         <label class="subscribe">
-          <input type="checkbox" checked name="subscribe">Subscribe to this topic
+          <input type="checkbox" checked name="subscribe" class="subscribe-checkbox">Subscribe to this topic
         </label>
       {% endif %}
       <a href=".." class="btn link cancel_form">Cancel</a>

http://git-wip-us.apache.org/repos/asf/allura/blob/d69e4176/ForgeBlog/forgeblog/templates/blog_widgets/post_form.html
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/templates/blog_widgets/post_form.html b/ForgeBlog/forgeblog/templates/blog_widgets/post_form.html
index 9030e87..4790d3e 100644
--- a/ForgeBlog/forgeblog/templates/blog_widgets/post_form.html
+++ b/ForgeBlog/forgeblog/templates/blog_widgets/post_form.html
@@ -53,7 +53,7 @@
     {% endfor %}
     {% if c.user and c.user != c.user.anonymous() and widget.fields.subscribe|default and not subscribed_to_tool %}
       <label class="subscribe">
-        <input type="checkbox" checked name="subscribe">Subscribe to this blog post
+        <input type="checkbox" checked name="subscribe" class="subscribe-checkbox">Subscribe to this blog post
       </label>
     {% endif %}
     <a href="{{c.app.url}}" class="btn link cancel_form">Cancel</a>

http://git-wip-us.apache.org/repos/asf/allura/blob/d69e4176/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html b/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html
index bf280f8..3afc9eb 100644
--- a/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html
+++ b/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html
@@ -128,7 +128,7 @@
     {{widget.display_field_by_name('submit')|safe}}
     {% if c.user and c.user != c.user.anonymous() and not ticket and not subscribed_to_tool|default %}
         <label class="subscribe">
-          <input type="checkbox" checked name="ticket_form.subscribe">Subscribe to this ticket
+          <input type="checkbox" checked name="ticket_form.subscribe" class="subscribe-checkbox">Subscribe to this ticket
         </label>
     {% endif %}
     <a href="{{c.app.url}}" class="btn link cancel_form">Cancel</a>

http://git-wip-us.apache.org/repos/asf/allura/blob/d69e4176/ForgeWiki/forgewiki/templates/wiki/page_edit.html
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/page_edit.html b/ForgeWiki/forgewiki/templates/wiki/page_edit.html
index 2b468e8..0fbadad 100644
--- a/ForgeWiki/forgewiki/templates/wiki/page_edit.html
+++ b/ForgeWiki/forgewiki/templates/wiki/page_edit.html
@@ -72,7 +72,7 @@
     <input type="reset" value="Cancel">
     {% if c.user and c.user != c.user.anonymous() and not subscribed_to_tool %}
       <label class="subscribe">
-        <input type="checkbox" checked name="subscribe">Subscribe to this wiki page
+        <input type="checkbox" checked name="subscribe" class="subscribe-checkbox">Subscribe to this wiki page
       </label>
     {% endif %}
 	</div>


[06/11] allura git commit: [#5461] option whether or not to subscribe when commenting

Posted by br...@apache.org.
[#5461] option whether or not to subscribe when commenting


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

Branch: refs/heads/db/5461
Commit: b93083462022317fa61be78efe599cbc882f7954
Parents: dbd45bb
Author: Dave Brondsema <da...@brondsema.net>
Authored: Tue Dec 18 17:02:42 2018 -0500
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Wed Dec 19 12:08:05 2018 -0500

----------------------------------------------------------------------
 Allura/allura/lib/widgets/discuss.py                   |  1 +
 Allura/allura/model/discuss.py                         |  5 +++--
 Allura/allura/templates/widgets/edit_post.html         | 13 ++++++++++---
 ForgeDiscussion/forgediscussion/model/forum.py         |  3 +--
 .../templates/discussionforums/thread.html             |  2 +-
 5 files changed, 16 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/b9308346/Allura/allura/lib/widgets/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/discuss.py b/Allura/allura/lib/widgets/discuss.py
index 2829a49..e07e73c 100644
--- a/Allura/allura/lib/widgets/discuss.py
+++ b/Allura/allura/lib/widgets/discuss.py
@@ -157,6 +157,7 @@ class EditPost(ff.ForgeForm):
         fields = ew_core.NameList()
         fields.append(ffw.MarkdownEdit(name='text'))
         fields.append(ew.HiddenField(name='forum', if_missing=None))
+        fields.append(ew.Checkbox(name='subscribe', label='Subscribe', if_missing=False))
         if ew_core.widget_context.widget:
             # we are being displayed
             if ew_core.widget_context.render_context.get('show_subject', self.show_subject):

http://git-wip-us.apache.org/repos/asf/allura/blob/b9308346/Allura/allura/model/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index 240f2eb..c6cbc58 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -303,10 +303,11 @@ class Thread(Artifact, ActivityObject):
 
     def post(self, text, message_id=None, parent_id=None, notify=True,
              notification_text=None, timestamp=None, ignore_security=False,
-             is_meta=False, **kw):
+             is_meta=False, subscribe=False, **kw):
         if not ignore_security:
             require_access(self, 'post')
-        self.primary().subscribe()
+        if subscribe:
+            self.primary().subscribe()
         if message_id is None:
             message_id = h.gen_message_id()
         parent = parent_id and self.post_class().query.get(_id=parent_id)

http://git-wip-us.apache.org/repos/asf/allura/blob/b9308346/Allura/allura/templates/widgets/edit_post.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/edit_post.html b/Allura/allura/templates/widgets/edit_post.html
index f47fcf8..939ed3d 100644
--- a/Allura/allura/templates/widgets/edit_post.html
+++ b/Allura/allura/templates/widgets/edit_post.html
@@ -28,10 +28,17 @@
     <input type="hidden" class="original_value" value="{{value.text}}">
     <span class="arw"><span></span></span>
     <div style="clear:both"></div>
-    <input type="submit" value="{{submit_text}}" />
-    <a href="#" class="ui-button btn link cancel_edit_post">Cancel</a>&nbsp;
     <a href="#" class="btn link attachment_form_add_button">Add attachments</a>
-    <input type="file" class="text attachment_form_fields" style="display:none" multiple="True" name="{{att_name}}" {% if att_id %}id="{{att_id}}"{% endif %}/>
+    <input type="file" class="text attachment_form_fields" style="display:none" multiple name="{{att_name}}" {% if att_id %}id="{{att_id}}"{% endif %}/>
+    <br>
+    <input type="submit" value="{{submit_text}}" />
+    {% if c.user and c.user != c.user.anonymous() %}
+      {# TODO: if not already subscribed (to artifact, or to whole tool) #}
+      <label class="subscribe">
+        <input type="checkbox" checked name="subscribe">Subscribe to this topic
+      </label>
+    {% endif %}
+    <a href="#" class="ui-button btn link cancel_edit_post">Cancel</a>
   {% if widget.antispam %}{% for fld in g.antispam.extra_fields() %}
   {{fld}}{% endfor %}{% endif %}
     {{lib.csrf_token()}}

http://git-wip-us.apache.org/repos/asf/allura/blob/b9308346/ForgeDiscussion/forgediscussion/model/forum.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/model/forum.py b/ForgeDiscussion/forgediscussion/model/forum.py
index 1796f23..96728ee 100644
--- a/ForgeDiscussion/forgediscussion/model/forum.py
+++ b/ForgeDiscussion/forgediscussion/model/forum.py
@@ -182,8 +182,7 @@ class ForumThread(M.Thread):
         return self
 
     def post(self, subject, text, message_id=None, parent_id=None, **kw):
-        post = super(ForumThread, self).post(
-            text, message_id=message_id, parent_id=parent_id, **kw)
+        post = super(ForumThread, self).post(text, message_id=message_id, parent_id=parent_id, **kw)
         if not self.first_post_id:
             self.first_post_id = post._id
             self.num_replies = 1

http://git-wip-us.apache.org/repos/asf/allura/blob/b9308346/ForgeDiscussion/forgediscussion/templates/discussionforums/thread.html
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/templates/discussionforums/thread.html b/ForgeDiscussion/forgediscussion/templates/discussionforums/thread.html
index 82e2ee7..f6cb8d5 100644
--- a/ForgeDiscussion/forgediscussion/templates/discussionforums/thread.html
+++ b/ForgeDiscussion/forgediscussion/templates/discussionforums/thread.html
@@ -31,7 +31,7 @@
   {% endif %}
   {# {{ g.icons['tag'].render(title='Label This', extra_css='thread_tag') }}   these labels aren't used anywhere ... #}
   {{ g.icons['feed'].render(href='feed.rss', title='Follow This', extra_css='thread_feed0') }}
-  {{ c.thread_subscription_form.display(value=thread.subscribed(), action='subscribe', style='icon', thing='thread') }}
+  {{ c.thread_subscription_form.display(value=thread.subscribed(), action='subscribe', style='icon', thing='topic') }}
 {% endblock %}
 
 {% block edit_box %}


[02/11] allura git commit: [#5461] make post cancel button work

Posted by br...@apache.org.
[#5461] make post cancel button work


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

Branch: refs/heads/db/5461
Commit: dbd45bbbfb050a9db34eb3a26dfaf58724009d8b
Parents: a94c28b
Author: Dave Brondsema <da...@brondsema.net>
Authored: Tue Dec 18 14:32:10 2018 -0500
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Tue Dec 18 14:32:10 2018 -0500

----------------------------------------------------------------------
 Allura/allura/lib/widgets/discuss.py                    | 10 ++++++----
 Allura/allura/public/nf/js/allura-base.js               |  4 ++++
 ForgeTracker/forgetracker/templates/tracker/ticket.html |  2 --
 3 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/dbd45bbb/Allura/allura/lib/widgets/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/discuss.py b/Allura/allura/lib/widgets/discuss.py
index 1a38101..2829a49 100644
--- a/Allura/allura/lib/widgets/discuss.py
+++ b/Allura/allura/lib/widgets/discuss.py
@@ -181,9 +181,13 @@ class EditPost(ff.ForgeForm):
                 evt.preventDefault();
             });
             $("a.cancel_edit_post").click(function(evt){
-                $("textarea", this.parentNode).val($("input.original_value", this.parentNode).val());
-                $(".attachment_form_fields input", this.parentNode).val('');
                 evt.preventDefault();
+                var form = this.parentNode;
+                var orig_val = $("input.original_value", form).val();
+                $("textarea", form).val(orig_val);
+                get_cm(form).setValue(orig_val);
+                $("input.attachment_form_fields", form).val('');
+                $(this).closest('.reply_post_form').hide();
             });
          });''')
 
@@ -368,8 +372,6 @@ class Post(HierWidget):
                     }
                 }
 
-                function get_cm($elem) { return $('.CodeMirror', $elem)[0].CodeMirror; }
-
                 if($('a.edit_post', post)){
                     $('a.edit_post', post).click(function (evt) {
                         evt.preventDefault();

http://git-wip-us.apache.org/repos/asf/allura/blob/dbd45bbb/Allura/allura/public/nf/js/allura-base.js
----------------------------------------------------------------------
diff --git a/Allura/allura/public/nf/js/allura-base.js b/Allura/allura/public/nf/js/allura-base.js
index b59fbe2..ce813a9 100644
--- a/Allura/allura/public/nf/js/allura-base.js
+++ b/Allura/allura/public/nf/js/allura-base.js
@@ -162,6 +162,10 @@ function addCommas(num) {
     return String(num).replace(new RegExp('(\\d)(?=(\\d\\d\\d)+(?!\\d))', 'g'), "$1,");
 }
 
+function get_cm($elem) {
+    return $('.CodeMirror', $elem)[0].CodeMirror;
+}
+
 $(function(){
     $('html').removeClass('no-js').addClass('js');
 

http://git-wip-us.apache.org/repos/asf/allura/blob/dbd45bbb/ForgeTracker/forgetracker/templates/tracker/ticket.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker/ticket.html b/ForgeTracker/forgetracker/templates/tracker/ticket.html
index 666775f..ec13e24 100644
--- a/ForgeTracker/forgetracker/templates/tracker/ticket.html
+++ b/ForgeTracker/forgetracker/templates/tracker/ticket.html
@@ -193,8 +193,6 @@
           var title_actions = title_holder.find('small');
           var vote = $('#vote');
 
-          function get_cm($elem) { return $('.CodeMirror', $elem)[0].CodeMirror; }
-
           var discussion_comment_cm = get_cm($('#new_post_holder'));
 
           $('a.edit_ticket').click(function () {


[03/11] allura git commit: [#5461] subscribe option on tickets, and tighten up new/edit form

Posted by br...@apache.org.
[#5461] subscribe option on tickets, and tighten up new/edit form


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

Branch: refs/heads/db/5461
Commit: b451b99c7ecdaa8e23a4fbe78fa74b0f02462ca9
Parents: 98aed3e
Author: Dave Brondsema <da...@brondsema.net>
Authored: Tue Dec 18 17:52:34 2018 -0500
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Wed Dec 19 12:08:05 2018 -0500

----------------------------------------------------------------------
 ForgeTracker/forgetracker/model/ticket.py         |  8 +++++---
 .../templates/tracker_widgets/ticket_form.html    | 18 +++++++++---------
 ForgeTracker/forgetracker/widgets/ticket_form.py  |  6 +-----
 3 files changed, 15 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/b451b99c/ForgeTracker/forgetracker/model/ticket.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/model/ticket.py b/ForgeTracker/forgetracker/model/ticket.py
index 580bd51..3e37ea6 100644
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -867,7 +867,7 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
         return False
     discussion_disabled = property(_get_discussion_disabled, _set_discussion_disabled)
 
-    def commit(self, **kwargs):
+    def commit(self, subscribe=False, **kwargs):
         VersionedArtifact.commit(self)
         monitoring_email = self.app.config.options.get('TicketMonitoringEmail')
         if self.version > 1:
@@ -911,7 +911,8 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
                         tofile='description-new')))
             description = '\n'.join(changes)
         else:
-            self.subscribe()
+            if subscribe:
+                self.subscribe()
             if self.assigned_to_id:
                 user = User.query.get(_id=self.assigned_to_id)
                 g.statsUpdater.ticketEvent(
@@ -955,6 +956,7 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
     def update(self, ticket_form):
         # update is not allowed to change the ticket_num
         ticket_form.pop('ticket_num', None)
+        subscribe = ticket_form.pop('subscribe', False)
         self.labels = ticket_form.pop('labels', [])
         custom_users = set()
         other_custom_fields = set()
@@ -997,7 +999,7 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
             # flush the session to make attachments available in the
             # notification email
             ThreadLocalORMSession.flush_all()
-        self.commit()
+        self.commit(subscribe=subscribe)
 
     def _move_attach(self, attachments, attach_metadata, app_config):
         for attach in attachments:

http://git-wip-us.apache.org/repos/asf/allura/blob/b451b99c/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html b/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html
index cfa90ab..be256c1 100644
--- a/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html
+++ b/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html
@@ -45,8 +45,8 @@
   {% set min_c_fields = widget.fields['_milestone'] and 1 or 0 %}
   {% if c.app.globals.custom_fields and c.app.globals.custom_fields.__len__() > min_c_fields %}
     {{widget.display_field_by_name('custom_fields', ignore_errors=True)}}
+    <div style="clear:both">&nbsp;</div>
   {% endif %}
-  <div style="clear:both">&nbsp;</div>
   <div class="grid-12">
     <label class="cr">Labels:</label>
     {{widget.display_field_by_name('labels')|safe}}
@@ -90,7 +90,8 @@
   </div>
   <div style="clear:both">&nbsp;</div>
   <div class="grid-18">
-    {% if ticket %}
+    <label class="simple">Attachments:</label>
+    {% if ticket and ticket.attachments %}
       <div class="clearfix">
       {% for att in ticket.attachments %}
           <div class="attachment_thumb">
@@ -104,15 +105,8 @@
           </div>
       {% endfor %}
       </div>
-      <div style="clear:both">&nbsp;</div>
     {% endif %}
-    <div>
-      <a href="#" id="show_attach">Add attachments</a>
-    </div>
-    <div style="clear:both">&nbsp;</div>
-    <div id="view_attach" style="display:none">
       {{widget.display_field_by_name('attachment')|safe}}
-    </div>
   </div>
   <div style="clear:both">&nbsp;</div>
   <div class="reply" style="position:relative;{% if not show_comment %} display:none{% endif %}">
@@ -132,6 +126,12 @@
   <div style="clear:both">&nbsp;</div>
   <div class="grid-18">
     {{widget.display_field_by_name('submit')|safe}}
+    {% if c.user and c.user != c.user.anonymous() and not ticket %}
+        {# TODO: if not already subscribed to whole tool #}
+        <label class="subscribe">
+          <input type="checkbox" checked name="ticket_form.subscribe">Subscribe to this ticket
+        </label>
+    {% endif %}
     <a href="{{c.app.url}}" class="btn link cancel_form">Cancel</a>
   </div>
   {{lib.csrf_token()}}

http://git-wip-us.apache.org/repos/asf/allura/blob/b451b99c/ForgeTracker/forgetracker/widgets/ticket_form.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/widgets/ticket_form.py b/ForgeTracker/forgetracker/widgets/ticket_form.py
index 24b97cb..5481eb2 100644
--- a/ForgeTracker/forgetracker/widgets/ticket_form.py
+++ b/ForgeTracker/forgetracker/widgets/ticket_form.py
@@ -129,6 +129,7 @@ class GenericTicketForm(ew.SimpleForm):
                                 'class': "ui-button ui-widget ui-state-default ui-button-text-only"}),
             ew.HiddenField(name='ticket_num',
                            validator=fev.Int(if_missing=None)),
+            ew.Checkbox(name='subscribe', label='Subscribe'),
         ]
         # milestone is kind of special because of the layout
         # add it to the main form rather than handle with the other customs
@@ -157,11 +158,6 @@ class TicketForm(GenericTicketForm):
         // Sometimes IE11 is not firing jQuery's ready callbacks like
         // "$(function(){...})" or "$(document).ready(function(){...});"
         $(window).load(function(){
-            $('#show_attach').click(function(evt) {
-                $('#view_attach').show();
-                $('#show_attach').hide();
-                evt.preventDefault();
-            });
             $('form').submit(function() {
                 $('input[type=submit]', this).prop('disabled', true);
             });


[10/11] allura git commit: [#5461] don't show subscribe checkbox if already subscribed to the tool

Posted by br...@apache.org.
[#5461] don't show subscribe checkbox if already subscribed to the tool


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

Branch: refs/heads/db/5461
Commit: ce7f141790c62fea25ab6634ec5c380cc888971f
Parents: 5170721
Author: Dave Brondsema <da...@brondsema.net>
Authored: Thu Dec 20 11:58:15 2018 -0500
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Fri Dec 21 12:07:41 2018 -0500

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py         |  9 ++++---
 Allura/allura/lib/widgets/repo.py               | 13 +++++----
 Allura/allura/model/artifact.py                 | 23 +++++++++-------
 Allura/allura/templates/widgets/edit_post.html  |  3 +--
 .../templates/widgets/new_topic_post.html       |  4 +--
 .../allura/templates/widgets/threads_table.html |  2 +-
 Allura/allura/tests/model/test_artifact.py      | 28 ++++++++++++++++++++
 ForgeBlog/forgeblog/main.py                     |  8 ++++--
 .../forgeblog/templates/blog/edit_post.html     |  2 +-
 .../templates/blog_widgets/post_form.html       |  3 +--
 .../forgediscussion/controllers/root.py         | 12 +++++----
 ForgeDiscussion/forgediscussion/model/forum.py  | 13 +++++++++
 .../discussion_widgets/add_forum_short.html     |  4 +--
 .../discussionforums/create_topic.html          |  3 ++-
 .../templates/tracker/new_ticket.html           |  2 +-
 .../templates/tracker_widgets/ticket_form.html  |  3 +--
 ForgeTracker/forgetracker/tracker_main.py       |  6 ++++-
 .../forgewiki/templates/wiki/page_edit.html     |  3 +--
 ForgeWiki/forgewiki/wiki_main.py                |  7 +++--
 19 files changed, 103 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/ce7f1417/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index db5f9a4..48a80f8 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -45,7 +45,7 @@ from allura.lib.diff import HtmlSideBySideDiff
 from allura.lib.security import require_access, require_authenticated, has_access
 from allura.lib.widgets import form_fields as ffw
 from allura.lib.widgets.repo import SCMLogWidget, SCMRevisionWidget, SCMTreeWidget
-from allura.lib.widgets.repo import SCMMergeRequestWidget, SCMMergeRequestWidgetNew
+from allura.lib.widgets.repo import SCMMergeRequestWidget
 from allura.lib.widgets.repo import SCMMergeRequestDisposeWidget, SCMCommitBrowserWidget
 from allura.lib.widgets.subscriptions import SubscribeForm
 from allura.controllers import AppDiscussionController
@@ -162,9 +162,12 @@ class RepoRootController(BaseController, FeedController):
             target_branches = [
                 b.name
                 for b in c.app.repo.get_branches() + c.app.repo.get_tags()]
-        return SCMMergeRequestWidgetNew(
+            subscribed_to_upstream = M.Mailbox.subscribed()
+        return SCMMergeRequestWidget(
             source_branches=source_branches,
-            target_branches=target_branches)
+            target_branches=target_branches,
+            show_subscribe_checkbox=not subscribed_to_upstream,
+        )
 
     @without_trailing_slash
     @expose('jinja:allura:templates/repo/request_merge.html')

http://git-wip-us.apache.org/repos/asf/allura/blob/ce7f1417/Allura/allura/lib/widgets/repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/repo.py b/Allura/allura/lib/widgets/repo.py
index 3a9e7d9..60d358f 100644
--- a/Allura/allura/lib/widgets/repo.py
+++ b/Allura/allura/lib/widgets/repo.py
@@ -63,6 +63,7 @@ class SCMTreeWidget(ew_core.Widget):
 class SCMMergeRequestWidget(ff.ForgeForm):
     source_branches = []
     target_branches = []
+    show_subscribe_checkbox = False
 
     @property
     def fields(self):
@@ -81,15 +82,13 @@ class SCMMergeRequestWidget(ff.ForgeForm):
             ffw.MarkdownEdit(name='description')]
         return result
 
-
-class SCMMergeRequestWidgetNew(SCMMergeRequestWidget):
-
     @property
     def buttons(self):
-        # add to after the default submit button
-        return ew_core.NameList([
-            ew.Checkbox(name='subscribe', label='Subscribe to this merge request', value=True),
-        ])
+        # add things after the default submit button
+        fields = ew_core.NameList()
+        if self.show_subscribe_checkbox:
+            fields.append(ew.Checkbox(name='subscribe', label='Subscribe to this merge request', value=True))
+        return fields
 
 
 class SCMMergeRequestDisposeWidget(ff.ForgeForm):

http://git-wip-us.apache.org/repos/asf/allura/blob/ce7f1417/Allura/allura/model/artifact.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/artifact.py b/Allura/allura/model/artifact.py
index 8ae24c6..8f9c5b6 100644
--- a/Allura/allura/model/artifact.py
+++ b/Allura/allura/model/artifact.py
@@ -34,11 +34,10 @@ from allura.lib import security
 from allura.lib import utils
 from allura.lib import plugin
 from allura.lib import exceptions as forge_exc
-
+from allura.lib.decorators import memoize
 from allura.lib.search import SearchIndexable
 from .session import main_orm_session
 from .session import project_orm_session
-
 from .session import artifact_orm_session
 from .index import ArtifactReference
 from .types import ACL, MarkdownCache
@@ -233,16 +232,22 @@ class Artifact(MappedClass, SearchIndexable):
             app_config_id=self.app_config._id,
             artifact_index_id=self.index_id())
 
-    def subscribed(self, user=None):
+    @memoize  # since its called many times from edit_post.html within threaded comments
+    def subscribed(self, user=None, include_parents=True):
         from allura.model import Mailbox
         if user is None:
             user = c.user
-        return Mailbox.subscribed(
-            user_id=user._id,
-            project_id=self.app_config.project_id,
-            app_config_id=self.app_config._id,
-            artifact=self,
-        )
+        user_proj_app_q = dict(user_id=user._id,
+                               project_id=self.app_config.project_id,
+                               app_config_id=self.app_config._id)
+        art_subscribed = Mailbox.subscribed(artifact=self, **user_proj_app_q)
+        if art_subscribed:
+            return True
+        if include_parents:
+            tool_subscribed = Mailbox.subscribed(**user_proj_app_q)
+            if tool_subscribed:
+                return True
+        return False
 
     def primary(self):
         """If an artifact is a "secondary" artifact (discussion of a ticket, for

http://git-wip-us.apache.org/repos/asf/allura/blob/ce7f1417/Allura/allura/templates/widgets/edit_post.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/edit_post.html b/Allura/allura/templates/widgets/edit_post.html
index 63181b8..49a8242 100644
--- a/Allura/allura/templates/widgets/edit_post.html
+++ b/Allura/allura/templates/widgets/edit_post.html
@@ -32,8 +32,7 @@
     <input type="file" class="text attachment_form_fields" style="display:none" multiple name="{{att_name}}" {% if att_id %}id="{{att_id}}"{% endif %}/>
     <br>
     <input type="submit" value="{{submit_text}}" />
-    {% if primary_artifact and c.user and c.user != c.user.anonymous() %}
-      {# TODO: if not already subscribed (to artifact, or to whole tool) #}
+    {% if primary_artifact and c.user and c.user != c.user.anonymous() and not primary_artifact.subscribed() %}
       <label class="subscribe">
         <input type="checkbox" checked name="subscribe">Subscribe to this {{ primary_artifact.type_name }}
       </label>

http://git-wip-us.apache.org/repos/asf/allura/blob/ce7f1417/Allura/allura/templates/widgets/new_topic_post.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/new_topic_post.html b/Allura/allura/templates/widgets/new_topic_post.html
index 46c806b..8910187 100644
--- a/Allura/allura/templates/widgets/new_topic_post.html
+++ b/Allura/allura/templates/widgets/new_topic_post.html
@@ -49,8 +49,8 @@
     <div class="grid-19">&nbsp;</div>
     <div class="grid-19">
       <input type="submit" value="{{submit_text}}">
-      {% if c.user and c.user != c.user.anonymous() %}
-          {# TODO: if not already subscribed to whole tool, or to forum #}
+      {% if c.user and c.user != c.user.anonymous() and not (subscribed or subscribed_to_tool) %}
+        {# subscribed is per-forum and won't change if they change the forum dropdown value, but better than nothing? :( #}
         <label class="subscribe">
           <input type="checkbox" checked name="subscribe">Subscribe to this topic
         </label>

http://git-wip-us.apache.org/repos/asf/allura/blob/ce7f1417/Allura/allura/templates/widgets/threads_table.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/threads_table.html b/Allura/allura/templates/widgets/threads_table.html
index c4f3d0b..e259446 100644
--- a/Allura/allura/templates/widgets/threads_table.html
+++ b/Allura/allura/templates/widgets/threads_table.html
@@ -40,7 +40,7 @@
         {% if not c.user.is_anonymous() and allow_subscriptions %}
           <td>
             <input type="checkbox" name="threads-{{loop.index0}}.subscription"
-                   {%- if thread.subscribed() or forum_subscribed or tool_subscribed %} checked="checked" {% endif -%}
+                   {%- if thread.subscribed(include_parents=False) or forum_subscribed or tool_subscribed %} checked="checked" {% endif -%}
                    {%- if forum_subscribed or tool_subscribed %}
                         disabled title="You are subscribed to this entire {% if forum_subscribed %}Forum. Unsubscribe with mail icon in upper right, or on Account - Subscriptions page.
                             {%- else %}Discussion tool.  Unsubscribe on Account - Subscriptions page.{% endif %}"

http://git-wip-us.apache.org/repos/asf/allura/blob/ce7f1417/Allura/allura/tests/model/test_artifact.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_artifact.py b/Allura/allura/tests/model/test_artifact.py
index 02a3052..017d0d3 100644
--- a/Allura/allura/tests/model/test_artifact.py
+++ b/Allura/allura/tests/model/test_artifact.py
@@ -299,3 +299,31 @@ def test_feed_from_username():
            title='Something')
     ThreadLocalORMSession.flush_all()
     assert_equal(len(M.Feed.from_username('johndoe')), 1)
+
+
+@with_setup(setUp, tearDown)
+def test_subscribed():
+    pg = WM.Page(title='TestPage4a')
+    assert pg.subscribed(include_parents=True)  # tool is subscribed to admins by default
+    assert not pg.subscribed(include_parents=False)
+
+
+@with_setup(setUp, tearDown)
+def test_subscribed_no_tool_sub():
+    pg = WM.Page(title='TestPage4b')
+    M.Mailbox.unsubscribe(user_id=c.user._id,
+                          project_id=c.project._id,
+                          app_config_id=c.app.config._id)
+    pg.subscribe()
+    assert pg.subscribed(include_parents=True)
+    assert pg.subscribed(include_parents=False)
+
+
+@with_setup(setUp, tearDown)
+def test_not_subscribed():
+    pg = WM.Page(title='TestPage4c')
+    M.Mailbox.unsubscribe(user_id=c.user._id,
+                          project_id=c.project._id,
+                          app_config_id=c.app.config._id)
+    assert not pg.subscribed(include_parents=True)
+    assert not pg.subscribed(include_parents=False)

http://git-wip-us.apache.org/repos/asf/allura/blob/ce7f1417/ForgeBlog/forgeblog/main.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index f4706d9..7205610 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -296,7 +296,9 @@ class RootController(BaseController, FeedController):
         post = dict(
             state='published')
         c.form = W.new_post_form
-        return dict(post=post)
+        return dict(post=post,
+                    subscribed_to_tool=M.Mailbox.subscribed(),
+                    )
 
     @memorable_forget()
     @expose()
@@ -390,7 +392,9 @@ class PostController(BaseController, FeedController):
         self.rate_limit(BM.BlogPost, 'Create/edit', c.app.config.url())
         c.form = W.edit_post_form
         c.attachment_list = W.attachment_list
-        return dict(post=self.post)
+        return dict(post=self.post,
+                    subscribed_to_tool=M.Mailbox.subscribed(),
+                    )
 
     @without_trailing_slash
     @expose('jinja:forgeblog:templates/blog/post_history.html')

http://git-wip-us.apache.org/repos/asf/allura/blob/ce7f1417/ForgeBlog/forgeblog/templates/blog/edit_post.html
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/templates/blog/edit_post.html b/ForgeBlog/forgeblog/templates/blog/edit_post.html
index c908a67..aa34e53 100644
--- a/ForgeBlog/forgeblog/templates/blog/edit_post.html
+++ b/ForgeBlog/forgeblog/templates/blog/edit_post.html
@@ -26,6 +26,6 @@
 
 {% block content %}
     <div class="content">
-      {{c.form.display(value=post, action='save')}}
+      {{c.form.display(value=post, action='save', subscribed_to_tool=subscribed_to_tool)}}
     </div>
 {% endblock %}

http://git-wip-us.apache.org/repos/asf/allura/blob/ce7f1417/ForgeBlog/forgeblog/templates/blog_widgets/post_form.html
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/templates/blog_widgets/post_form.html b/ForgeBlog/forgeblog/templates/blog_widgets/post_form.html
index 6a4f5ba..9030e87 100644
--- a/ForgeBlog/forgeblog/templates/blog_widgets/post_form.html
+++ b/ForgeBlog/forgeblog/templates/blog_widgets/post_form.html
@@ -51,8 +51,7 @@
     {% for b in buttons %}
       {{b.display()}}
     {% endfor %}
-    {% if c.user and c.user != c.user.anonymous() and widget.fields.subscribe|default %}
-      {# TODO: if not already subscribed to whole tool #}
+    {% if c.user and c.user != c.user.anonymous() and widget.fields.subscribe|default and not subscribed_to_tool %}
       <label class="subscribe">
         <input type="checkbox" checked name="subscribe">Subscribe to this blog post
       </label>

http://git-wip-us.apache.org/repos/asf/allura/blob/ce7f1417/ForgeDiscussion/forgediscussion/controllers/root.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/controllers/root.py b/ForgeDiscussion/forgediscussion/controllers/root.py
index bc70dbe..55c2e1f 100644
--- a/ForgeDiscussion/forgediscussion/controllers/root.py
+++ b/ForgeDiscussion/forgediscussion/controllers/root.py
@@ -39,6 +39,7 @@ from allura.lib.decorators import require_post, memorable_forget
 from allura.controllers import BaseController, DispatchIndex
 from allura.controllers.rest import AppRestControllerMixin
 from allura.controllers.feed import FeedArgs, FeedController
+from allura import model as M
 
 from .forum import ForumController
 from forgediscussion import import_support
@@ -73,8 +74,6 @@ class RootController(BaseController, DispatchIndex, FeedController):
     @with_trailing_slash
     @expose('jinja:forgediscussion:templates/discussionforums/index.html')
     def index(self, new_forum=False, **kw):
-        c.new_topic = self.W.new_topic
-        c.new_topic = self.W.new_topic
         c.add_forum = self.W.add_forum
         c.announcements_table = self.W.announcements_table
         announcements = model.ForumThread.query.find(dict(
@@ -111,15 +110,18 @@ class RootController(BaseController, DispatchIndex, FeedController):
                                              deleted=False))
         c.new_topic = self.W.new_topic
         my_forums = []
-        forum_name = h.really_unicode(unquote(
-            forum_name)) if forum_name else None
+        forum_name = h.really_unicode(unquote(forum_name)) if forum_name else None
         current_forum = None
         for f in forums:
             if forum_name == f.shortname:
                 current_forum = f
             if has_access(f, 'post')():
                 my_forums.append(f)
-        return dict(forums=my_forums, current_forum=current_forum)
+        return dict(forums=my_forums,
+                    current_forum=current_forum,
+                    subscribed=M.Mailbox.subscribed(artifact=current_forum),
+                    subscribed_to_tool=M.Mailbox.subscribed(),
+                    )
 
     @memorable_forget()
     @h.vardec

http://git-wip-us.apache.org/repos/asf/allura/blob/ce7f1417/ForgeDiscussion/forgediscussion/model/forum.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/model/forum.py b/ForgeDiscussion/forgediscussion/model/forum.py
index 94cb053..ce54156 100644
--- a/ForgeDiscussion/forgediscussion/model/forum.py
+++ b/ForgeDiscussion/forgediscussion/model/forum.py
@@ -185,6 +185,19 @@ class ForumThread(M.Thread):
     def primary(self):
         return self
 
+    def subscribed(self, user=None, include_parents=True):
+        subbed = super(ForumThread, self).subscribed(user=user, include_parents=include_parents)
+        if subbed:
+            return subbed
+        if include_parents:
+            if user is None:
+                user = c.user
+            forum = self.discussion
+            forum_subscribed = M.Mailbox.subscribed(artifact=forum, user_id=user._id)
+            if forum_subscribed:
+                return True
+        return False
+
     def post(self, subject, text, message_id=None, parent_id=None, **kw):
         post = super(ForumThread, self).post(text, message_id=message_id, parent_id=parent_id, **kw)
         if not self.first_post_id:

http://git-wip-us.apache.org/repos/asf/allura/blob/ce7f1417/ForgeDiscussion/forgediscussion/templates/discussion_widgets/add_forum_short.html
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/templates/discussion_widgets/add_forum_short.html b/ForgeDiscussion/forgediscussion/templates/discussion_widgets/add_forum_short.html
index b949cf1..a302222 100644
--- a/ForgeDiscussion/forgediscussion/templates/discussion_widgets/add_forum_short.html
+++ b/ForgeDiscussion/forgediscussion/templates/discussion_widgets/add_forum_short.html
@@ -21,11 +21,11 @@
   <input type="hidden" name="add_forum.app_id" value="{{app and app.config._id}}">
   <div class="grid-6">
     <label class="cr">Forum Title:</label>
-    <input type="text" name="add_forum.name" style="width:90%"/>
+    <input type="text" name="add_forum.name" style="width:90%" required/>
   </div>
   <div class="grid-6">
     <label class="cr">Short Name (for URL):</label>
-    <input type="text" name="add_forum.shortname" style="width:90%"/>
+    <input type="text" name="add_forum.shortname" style="width:90%" required/>
   </div>
   <div class="grid-7">
     <label class="cr">Summary:</label>

http://git-wip-us.apache.org/repos/asf/allura/blob/ce7f1417/ForgeDiscussion/forgediscussion/templates/discussionforums/create_topic.html
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/templates/discussionforums/create_topic.html b/ForgeDiscussion/forgediscussion/templates/discussionforums/create_topic.html
index 852c2d6..487553c 100644
--- a/ForgeDiscussion/forgediscussion/templates/discussionforums/create_topic.html
+++ b/ForgeDiscussion/forgediscussion/templates/discussionforums/create_topic.html
@@ -30,7 +30,8 @@
   {% endif %}
 {% else %}
   <div class="editbox">
-    {{c.new_topic.display(action=c.app.url + 'save_new_topic',show_subject=True,forums=forums, current_forum=current_forum)}}
+    {{c.new_topic.display(action=c.app.url + 'save_new_topic', show_subject=True, forums=forums,
+                          current_forum=current_forum, subscribed=subscribed, subscribed_to_tool=subscribed_to_tool)}}
     <div class="clear"></div>
   </div>
 {% endif %}

http://git-wip-us.apache.org/repos/asf/allura/blob/ce7f1417/ForgeTracker/forgetracker/templates/tracker/new_ticket.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker/new_ticket.html b/ForgeTracker/forgetracker/templates/tracker/new_ticket.html
index e586a1c..b5c858d 100644
--- a/ForgeTracker/forgetracker/templates/tracker/new_ticket.html
+++ b/ForgeTracker/forgetracker/templates/tracker/new_ticket.html
@@ -25,7 +25,7 @@
 {% block edit_box %}
 <div class="editbox">
   <div class="form_holder">
-      {{c.ticket_form.display(action=action, value=url_params, help_msg=help_msg)}}
+      {{c.ticket_form.display(action=action, value=url_params, help_msg=help_msg, subscribed_to_tool=subscribed_to_tool)}}
   </div>
 </div>
 {% endblock %}

http://git-wip-us.apache.org/repos/asf/allura/blob/ce7f1417/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html b/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html
index be256c1..bf280f8 100644
--- a/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html
+++ b/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_form.html
@@ -126,8 +126,7 @@
   <div style="clear:both">&nbsp;</div>
   <div class="grid-18">
     {{widget.display_field_by_name('submit')|safe}}
-    {% if c.user and c.user != c.user.anonymous() and not ticket %}
-        {# TODO: if not already subscribed to whole tool #}
+    {% if c.user and c.user != c.user.anonymous() and not ticket and not subscribed_to_tool|default %}
         <label class="subscribe">
           <input type="checkbox" checked name="ticket_form.subscribe">Subscribe to this ticket
         </label>

http://git-wip-us.apache.org/repos/asf/allura/blob/ce7f1417/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index c065606..ad3b2b7 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -902,7 +902,11 @@ class RootController(BaseController, FeedController):
         self.rate_limit(TM.Ticket, 'Ticket creation', redir='..')
         c.ticket_form = W.ticket_form
         help_msg = c.app.config.options.get('TicketHelpNew', '').strip()
-        return dict(action=c.app.config.url() + 'save_ticket', help_msg=help_msg, url_params=kw)
+        return dict(action=c.app.config.url() + 'save_ticket',
+                    help_msg=help_msg,
+                    url_params=kw,
+                    subscribed_to_tool=M.Mailbox.subscribed(),
+                    )
 
     @expose('jinja:allura:templates/markdown_syntax.html')
     def markdown_syntax(self, **kw):

http://git-wip-us.apache.org/repos/asf/allura/blob/ce7f1417/ForgeWiki/forgewiki/templates/wiki/page_edit.html
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/page_edit.html b/ForgeWiki/forgewiki/templates/wiki/page_edit.html
index 2cb5f50..2b468e8 100644
--- a/ForgeWiki/forgewiki/templates/wiki/page_edit.html
+++ b/ForgeWiki/forgewiki/templates/wiki/page_edit.html
@@ -70,8 +70,7 @@
   <div class="grid-20">
     <input type="submit" value="Save">
     <input type="reset" value="Cancel">
-    {% if c.user and c.user != c.user.anonymous() %}
-      {# TODO: if not already subscribed to whole tool #}
+    {% if c.user and c.user != c.user.anonymous() and not subscribed_to_tool %}
       <label class="subscribe">
         <input type="checkbox" checked name="subscribe">Subscribe to this wiki page
       </label>

http://git-wip-us.apache.org/repos/asf/allura/blob/ce7f1417/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index cb5d893..c62ee0b 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -620,8 +620,11 @@ class PageController(BaseController, FeedController):
         c.attachment_list = W.attachment_list
         c.label_edit = W.label_edit
         hide_left_bar = not c.app.show_left_bar
-        return dict(page=page, page_exists=page_exists,
-                    hide_left_bar=hide_left_bar)
+        return dict(page=page,
+                    page_exists=page_exists,
+                    hide_left_bar=hide_left_bar,
+                    subscribed_to_tool=M.Mailbox.subscribed(),
+                    )
 
     @without_trailing_slash
     @expose('json:')


[09/11] allura git commit: [#5461] add subscribe option to new blog posts

Posted by br...@apache.org.
[#5461] add subscribe option to new blog posts


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

Branch: refs/heads/db/5461
Commit: 4a6f8c06c66f11e68f87c7a80888351d8a535c41
Parents: 3e066d0
Author: Dave Brondsema <da...@brondsema.net>
Authored: Wed Dec 19 12:35:35 2018 -0500
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Thu Dec 20 11:59:01 2018 -0500

----------------------------------------------------------------------
 ForgeBlog/forgeblog/main.py                     |  3 +-
 ForgeBlog/forgeblog/model/blog.py               |  8 ++-
 .../templates/blog_widgets/post_form.html       |  6 ++
 ForgeBlog/forgeblog/widgets.py                  | 58 +++++++++++++-------
 4 files changed, 50 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/4a6f8c06/ForgeBlog/forgeblog/main.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index 066c238..f4706d9 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -301,7 +301,8 @@ class RootController(BaseController, FeedController):
     @memorable_forget()
     @expose()
     @require_post()
-    @validate(form=W.edit_post_form, error_handler=new)
+    # both new & edit submit here, but validate with new since it adds a field (subscribe)
+    @validate(form=W.new_post_form, error_handler=new)
     @without_trailing_slash
     def save(self, **kw):
         require_access(c.app, 'write')

http://git-wip-us.apache.org/repos/asf/allura/blob/4a6f8c06/ForgeBlog/forgeblog/model/blog.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/model/blog.py b/ForgeBlog/forgeblog/model/blog.py
index f20b228..0cbd8df 100644
--- a/ForgeBlog/forgeblog/model/blog.py
+++ b/ForgeBlog/forgeblog/model/blog.py
@@ -234,10 +234,11 @@ class BlogPost(M.VersionedArtifact, ActivityObject):
         HC = self.__mongometa__.history_class
         return HC.query.find({'artifact_id': self._id, 'version': int(version)}).one()
 
-    def commit(self):
+    def commit(self, subscribe=False):
         activity = functools.partial(g.director.create_activity, c.user,
                                      related_nodes=[c.project], tags=['blog'])
-        self.subscribe()
+        if subscribe:
+            self.subscribe()
         super(BlogPost, self).commit()
         if self.version > 1:
             v1 = self.get_version(self.version - 1)
@@ -291,11 +292,12 @@ class BlogPost(M.VersionedArtifact, ActivityObject):
     @classmethod
     def new(cls, **kw):
         post = cls()
+        subscribe = kw.pop('subscribe', False)
         for k, v in kw.iteritems():
             setattr(post, k, v)
         post.neighborhood_id = c.project.neighborhood_id
         post.make_slug()
-        post.commit()
+        post.commit(subscribe=subscribe)
         M.Thread.new(
             discussion_id=post.app_config.discussion_id,
             ref_id=post.index_id(),

http://git-wip-us.apache.org/repos/asf/allura/blob/4a6f8c06/ForgeBlog/forgeblog/templates/blog_widgets/post_form.html
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/templates/blog_widgets/post_form.html b/ForgeBlog/forgeblog/templates/blog_widgets/post_form.html
index b8216b0..6a4f5ba 100644
--- a/ForgeBlog/forgeblog/templates/blog_widgets/post_form.html
+++ b/ForgeBlog/forgeblog/templates/blog_widgets/post_form.html
@@ -51,6 +51,12 @@
     {% for b in buttons %}
       {{b.display()}}
     {% endfor %}
+    {% if c.user and c.user != c.user.anonymous() and widget.fields.subscribe|default %}
+      {# TODO: if not already subscribed to whole tool #}
+      <label class="subscribe">
+        <input type="checkbox" checked name="subscribe">Subscribe to this blog post
+      </label>
+    {% endif %}
     <a href="{{c.app.url}}" class="btn link cancel_form">Cancel</a>
   </div>
   {% if widget.antispam %}{% for fld in g.antispam.extra_fields() %}

http://git-wip-us.apache.org/repos/asf/allura/blob/4a6f8c06/ForgeBlog/forgeblog/widgets.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/widgets.py b/ForgeBlog/forgeblog/widgets.py
index 6b055fc..0110b40 100644
--- a/ForgeBlog/forgeblog/widgets.py
+++ b/ForgeBlog/forgeblog/widgets.py
@@ -29,31 +29,38 @@ class BlogPager(ffw.PageList):
     template = 'jinja:forgeblog:templates/blog_widgets/page_list.html'
 
 
-class NewPostForm(forms.ForgeForm):
+class BlogPostForm(forms.ForgeForm):
     template = 'jinja:forgeblog:templates/blog_widgets/post_form.html'
     enctype = 'multipart/form-data'
 
-    class fields(ew_core.NameList):
-        title = ew.TextField(validator=fev.UnicodeString(not_empty=True,
-                             messages={'empty': "You must provide a Title"}),
-                             attrs=dict(placeholder='Enter your title here',
-                                        title='Enter your title here',
-                                        style='width: 425px'))
-        text = ffw.MarkdownEdit(show_label=False,
-                                attrs=dict(
-                                    placeholder='Enter your content here',
-                                    title='Enter your content here'))
-        state = ew.SingleSelectField(
-            options=[
-                ew.Option(py_value='draft', label='Draft'),
-                ew.Option(py_value='published', label='Published')])
-        labels = ffw.LabelEdit(placeholder='Add labels here',
-                               title='Add labels here')
-        attachment = ew.InputField(label='Attachment', field_type='file', attrs={'multiple': 'True'},
-                                   validator=fev.FieldStorageUploadConverter(if_missing=None))
+    @property
+    def fields(self):
+        return ew_core.NameList([
+            ew.TextField(name='title',
+                         validator=fev.UnicodeString(not_empty=True,
+                                                     messages={'empty': "You must provide a Title"}),
+                         attrs=dict(placeholder='Enter your title here',
+                                    title='Enter your title here',
+                                    style='width: 425px')),
+            ffw.MarkdownEdit(name='text',
+                             show_label=False,
+                             attrs=dict(
+                                 placeholder='Enter your content here',
+                                 title='Enter your content here')),
+            ew.SingleSelectField(name='state',
+                                 options=[
+                                     ew.Option(py_value='draft', label='Draft'),
+                                     ew.Option(py_value='published', label='Published')]),
+            ffw.LabelEdit(name='labels',
+                          placeholder='Add labels here',
+                          title='Add labels here'),
+            ew.InputField(name='attachment',
+                          label='Attachment', field_type='file', attrs={'multiple': 'True'},
+                          validator=fev.FieldStorageUploadConverter(if_missing=None)),
+        ])
 
     def resources(self):
-        for r in super(NewPostForm, self).resources():
+        for r in super(BlogPostForm, self).resources():
             yield r
         yield ew.JSScript('''
             $(function() {
@@ -62,7 +69,16 @@ class NewPostForm(forms.ForgeForm):
         ''')
 
 
-class EditPostForm(NewPostForm):
+class NewPostForm(BlogPostForm):
+
+    @property
+    def fields(self):
+        fields = super(NewPostForm, self).fields
+        fields.append(ew.Checkbox(name='subscribe'))
+        return fields
+
+
+class EditPostForm(BlogPostForm):
 
     class buttons(ew_core.NameList):
         delete = ew.SubmitButton(label='Delete')


[04/11] allura git commit: [#5461] show the relevant artifact type in the checkbox label

Posted by br...@apache.org.
[#5461] show the relevant artifact type in the checkbox label


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

Branch: refs/heads/db/5461
Commit: 3e066d0d9d33970d68e2eb64810dc8552eb21a0e
Parents: b451b99
Author: Dave Brondsema <da...@brondsema.net>
Authored: Wed Dec 19 12:07:19 2018 -0500
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Wed Dec 19 12:08:05 2018 -0500

----------------------------------------------------------------------
 Allura/allura/model/artifact.py                    | 8 ++++++++
 Allura/allura/templates/widgets/edit_post.html     | 4 ++--
 Allura/allura/templates/widgets/post_thread.html   | 4 ++--
 Allura/allura/templates/widgets/post_widget.html   | 7 ++++---
 Allura/allura/templates/widgets/thread_widget.html | 6 +++---
 ForgeDiscussion/forgediscussion/model/forum.py     | 4 ++++
 ForgeWiki/forgewiki/model/wiki.py                  | 4 ++++
 7 files changed, 27 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/3e066d0d/Allura/allura/model/artifact.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/artifact.py b/Allura/allura/model/artifact.py
index 74480f5..8ae24c6 100644
--- a/Allura/allura/model/artifact.py
+++ b/Allura/allura/model/artifact.py
@@ -329,6 +329,14 @@ class Artifact(MappedClass, SearchIndexable):
             snippet_s='',
             deleted_b=self.deleted)
 
+    @property
+    def type_name(self):
+        """
+        :return: a presentation name for this type of artifact
+        :rtype: str
+        """
+        return self.type_s.lower()
+
     def url(self):
         """Return the URL for this Artifact.
 

http://git-wip-us.apache.org/repos/asf/allura/blob/3e066d0d/Allura/allura/templates/widgets/edit_post.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/edit_post.html b/Allura/allura/templates/widgets/edit_post.html
index 939ed3d..63181b8 100644
--- a/Allura/allura/templates/widgets/edit_post.html
+++ b/Allura/allura/templates/widgets/edit_post.html
@@ -32,10 +32,10 @@
     <input type="file" class="text attachment_form_fields" style="display:none" multiple name="{{att_name}}" {% if att_id %}id="{{att_id}}"{% endif %}/>
     <br>
     <input type="submit" value="{{submit_text}}" />
-    {% if c.user and c.user != c.user.anonymous() %}
+    {% if primary_artifact and c.user and c.user != c.user.anonymous() %}
       {# TODO: if not already subscribed (to artifact, or to whole tool) #}
       <label class="subscribe">
-        <input type="checkbox" checked name="subscribe">Subscribe to this topic
+        <input type="checkbox" checked name="subscribe">Subscribe to this {{ primary_artifact.type_name }}
       </label>
     {% endif %}
     <a href="#" class="ui-button btn link cancel_edit_post">Cancel</a>

http://git-wip-us.apache.org/repos/asf/allura/blob/3e066d0d/Allura/allura/templates/widgets/post_thread.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/post_thread.html b/Allura/allura/templates/widgets/post_thread.html
index 40bc774..c593803 100644
--- a/Allura/allura/templates/widgets/post_thread.html
+++ b/Allura/allura/templates/widgets/post_thread.html
@@ -20,12 +20,12 @@
 <li>
 {{widget.parent_widget.widgets.post.display(
     value=value, show_subject=show_subject, indent=indent,
-    page=page, limit=limit)}}
+    page=page, limit=limit, primary_artifact=primary_artifact)}}
     <!-- post_thread replies -->
     <ul>
       {%- if children %}
       {%- for child in children %}
-      {{widget.display(value=child.post, children=child.children, indent=indent+1)}}
+      {{widget.display(value=child.post, children=child.children, indent=indent+1, primary_artifact=primary_artifact)}}
       {%- endfor %}
       {%- endif %}
     </ul>

http://git-wip-us.apache.org/repos/asf/allura/blob/3e066d0d/Allura/allura/templates/widgets/post_widget.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/post_widget.html b/Allura/allura/templates/widgets/post_widget.html
index bcca961..b6f6970 100644
--- a/Allura/allura/templates/widgets/post_widget.html
+++ b/Allura/allura/templates/widgets/post_widget.html
@@ -95,7 +95,7 @@
         </div>
         {% if h.has_access(value, 'moderate')() %}
         <div class="edit_post_form reply" style="display:none; padding-left: 5px;">
-            {{widgets.edit_post.display(value=value, submit_text='Post', action=value.url())}}
+            {{widgets.edit_post.display(value=value, submit_text='Post', action=value.url(), primary_artifact=primary_artifact)}}
         </div>
         {% endif %}
         {% if h.has_access(value, 'moderate')() %}
@@ -166,8 +166,9 @@
                 submit_text='Post Reply',
                 action=value.url()+'reply',
                 value=dict(
-                text='',
-                subject=value.reply_subject()),
+                    text='',
+                    subject=value.reply_subject()),
+                primary_artifact=primary_artifact,
               )}}
             </div>
           </div>

http://git-wip-us.apache.org/repos/asf/allura/blob/3e066d0d/Allura/allura/templates/widgets/thread_widget.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/thread_widget.html b/Allura/allura/templates/widgets/thread_widget.html
index d060c4d..2bd0f65 100644
--- a/Allura/allura/templates/widgets/thread_widget.html
+++ b/Allura/allura/templates/widgets/thread_widget.html
@@ -17,7 +17,7 @@
        under the License.
 -#}
 {% import 'allura:templates/jinja_master/lib.html' as lib with context %}
-
+{% set primary_artifact = value.primary() %}
 <div>
   <div class="comment-row">
       {% if limit %}
@@ -30,7 +30,7 @@
             <ul>
               {{widgets.post_thread.display(value=t['post'], children=t['children'],
                   indent=0, show_subject=show_subject,
-                  page=page, limit=limit)}}
+                  page=page, limit=limit, primary_artifact=primary_artifact)}}
             </ul>
             {% endfor %}
           {% endif %}
@@ -61,7 +61,7 @@
           </p>
         </div>
         <div class="grid-17">
-            {{widgets.edit_post.display(submit_text='Post', action=value.url() + 'post')}}
+            {{widgets.edit_post.display(submit_text='Post', action=value.url() + 'post', primary_artifact=primary_artifact)}}
         </div>
       </div>
     </div>

http://git-wip-us.apache.org/repos/asf/allura/blob/3e066d0d/ForgeDiscussion/forgediscussion/model/forum.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/model/forum.py b/ForgeDiscussion/forgediscussion/model/forum.py
index 96728ee..94cb053 100644
--- a/ForgeDiscussion/forgediscussion/model/forum.py
+++ b/ForgeDiscussion/forgediscussion/model/forum.py
@@ -164,6 +164,10 @@ class ForumThread(M.Thread):
     first_post = RelationProperty('ForumPost', via='first_post_id')
 
     @property
+    def type_name(self):
+        return 'topic'
+
+    @property
     def status(self):
         if len(self.posts) == 1:
             return self.posts[0].status

http://git-wip-us.apache.org/repos/asf/allura/blob/3e066d0d/ForgeWiki/forgewiki/model/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/model/wiki.py b/ForgeWiki/forgewiki/model/wiki.py
index bb9f452..bad7a72 100644
--- a/ForgeWiki/forgewiki/model/wiki.py
+++ b/ForgeWiki/forgewiki/model/wiki.py
@@ -119,6 +119,10 @@ class Page(VersionedArtifact, ActivityObject):
         return 'a wiki page'
 
     @property
+    def type_name(self):
+        return 'wiki page'
+
+    @property
     def activity_extras(self):
         d = ActivityObject.activity_extras.fget(self)
         d.update(summary=self.title)


[05/11] allura git commit: [#5461] subscription option for new forum topics

Posted by br...@apache.org.
[#5461] subscription option for new forum topics


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

Branch: refs/heads/db/5461
Commit: 98aed3e846f65d9fa026edb23c270a6f711dc6b5
Parents: b930834
Author: Dave Brondsema <da...@brondsema.net>
Authored: Tue Dec 18 17:10:39 2018 -0500
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Wed Dec 19 12:08:05 2018 -0500

----------------------------------------------------------------------
 .../ext/user_profile/templates/send_message_form.html       | 2 +-
 Allura/allura/templates/widgets/new_topic_post.html         | 9 ++++++++-
 ForgeDiscussion/forgediscussion/controllers/root.py         | 4 ++--
 3 files changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/98aed3e8/Allura/allura/ext/user_profile/templates/send_message_form.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/user_profile/templates/send_message_form.html b/Allura/allura/ext/user_profile/templates/send_message_form.html
index 06e4330..279572f 100644
--- a/Allura/allura/ext/user_profile/templates/send_message_form.html
+++ b/Allura/allura/ext/user_profile/templates/send_message_form.html
@@ -48,7 +48,7 @@
             {{widget.display_field(widget.fields.cc)}}
         </div>
         <div class="grid-19">&nbsp;</div>
-        <div class="grid-19">
+        <div class="grid-12">
             {{buttons[0].display()}}
             <a href="{{c.app.url}}" class="btn link cancel_form">Cancel</a>
         </div>

http://git-wip-us.apache.org/repos/asf/allura/blob/98aed3e8/Allura/allura/templates/widgets/new_topic_post.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/new_topic_post.html b/Allura/allura/templates/widgets/new_topic_post.html
index 12f74da..46c806b 100644
--- a/Allura/allura/templates/widgets/new_topic_post.html
+++ b/Allura/allura/templates/widgets/new_topic_post.html
@@ -48,7 +48,14 @@
     </div>
     <div class="grid-19">&nbsp;</div>
     <div class="grid-19">
-      <input type="submit" value="{{submit_text}}"> <a href=".." class="btn link">Cancel</a>
+      <input type="submit" value="{{submit_text}}">
+      {% if c.user and c.user != c.user.anonymous() %}
+          {# TODO: if not already subscribed to whole tool, or to forum #}
+        <label class="subscribe">
+          <input type="checkbox" checked name="subscribe">Subscribe to this topic
+        </label>
+      {% endif %}
+      <a href=".." class="btn link cancel_form">Cancel</a>
     </div>
   {% if widget.antispam %}{% for fld in g.antispam.extra_fields() %}
   {{fld}}{% endfor %}{% endif %}

http://git-wip-us.apache.org/repos/asf/allura/blob/98aed3e8/ForgeDiscussion/forgediscussion/controllers/root.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/controllers/root.py b/ForgeDiscussion/forgediscussion/controllers/root.py
index 0b5add6..bc70dbe 100644
--- a/ForgeDiscussion/forgediscussion/controllers/root.py
+++ b/ForgeDiscussion/forgediscussion/controllers/root.py
@@ -127,7 +127,7 @@ class RootController(BaseController, DispatchIndex, FeedController):
     @require_post()
     @validate(W.new_topic, error_handler=create_topic)
     @AntiSpam.validate('Spambot protection engaged')
-    def save_new_topic(self, subject=None, text=None, forum=None, **kw):
+    def save_new_topic(self, subject=None, text=None, forum=None, subscribe=False, **kw):
         self.rate_limit(model.ForumPost, 'Topic creation', request.referer)
         discussion = model.Forum.query.get(
             app_config_id=c.app.config._id,
@@ -138,7 +138,7 @@ class RootController(BaseController, DispatchIndex, FeedController):
         require_access(discussion, 'post')
         thd = discussion.get_discussion_thread(dict(
             headers=dict(Subject=subject)))[0]
-        p = thd.post(subject, text)
+        p = thd.post(subject, text, subscribe=subscribe)
         if 'attachment' in kw:
             p.add_multiple_attachments(kw['attachment'])
         thd.post_to_feed(p)


[08/11] allura git commit: [#5461] add subscribe option to wiki pages

Posted by br...@apache.org.
[#5461] add subscribe option to wiki pages


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

Branch: refs/heads/db/5461
Commit: 67fde47f5cf8bcb6b191532ddc44043d4f015adc
Parents: 4a6f8c0
Author: Dave Brondsema <da...@brondsema.net>
Authored: Wed Dec 19 14:05:46 2018 -0500
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Thu Dec 20 11:59:01 2018 -0500

----------------------------------------------------------------------
 ForgeWiki/forgewiki/model/wiki.py                 | 4 +++-
 ForgeWiki/forgewiki/templates/wiki/page_edit.html | 8 +++++++-
 ForgeWiki/forgewiki/wiki_main.py                  | 6 ++++--
 3 files changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/67fde47f/ForgeWiki/forgewiki/model/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/model/wiki.py b/ForgeWiki/forgewiki/model/wiki.py
index bad7a72..e55d464 100644
--- a/ForgeWiki/forgewiki/model/wiki.py
+++ b/ForgeWiki/forgewiki/model/wiki.py
@@ -147,7 +147,9 @@ class Page(VersionedArtifact, ActivityObject):
                     labels=list(self.labels),
                     attachments=self.attachments_for_export() if is_export else self.attachments_for_json())
 
-    def commit(self):
+    def commit(self, subscribe=False):
+        if subscribe:
+            self.subscribe()
         ss = VersionedArtifact.commit(self)
         session(self).flush()
         if self.version > 1:

http://git-wip-us.apache.org/repos/asf/allura/blob/67fde47f/ForgeWiki/forgewiki/templates/wiki/page_edit.html
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/page_edit.html b/ForgeWiki/forgewiki/templates/wiki/page_edit.html
index 204b20c..2cb5f50 100644
--- a/ForgeWiki/forgewiki/templates/wiki/page_edit.html
+++ b/ForgeWiki/forgewiki/templates/wiki/page_edit.html
@@ -67,9 +67,15 @@
 	<div class="grid-14" style="margin-left:0">
 		{{c.label_edit.display(id='labels', name='labels', value=page.labels)}}
   </div>
-  <div class="grid-19">
+  <div class="grid-20">
     <input type="submit" value="Save">
     <input type="reset" value="Cancel">
+    {% if c.user and c.user != c.user.anonymous() %}
+      {# TODO: if not already subscribed to whole tool #}
+      <label class="subscribe">
+        <input type="checkbox" checked name="subscribe">Subscribe to this wiki page
+      </label>
+    {% endif %}
 	</div>
     {{lib.csrf_token()}}
 </form>

http://git-wip-us.apache.org/repos/asf/allura/blob/67fde47f/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 64aaf8b..cb5d893 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -714,7 +714,9 @@ class PageController(BaseController, FeedController):
     def update(self, title=None, text=None,
                labels=None,
                viewable_by=None,
-               new_viewable_by=None, **kw):
+               new_viewable_by=None,
+               subscribe=False,
+               **kw):
         activity_verb = 'created'
         if not title:
             flash('You must provide a title for the page.', 'error')
@@ -745,7 +747,7 @@ class PageController(BaseController, FeedController):
             self.page.labels = labels.split(',')
         else:
             self.page.labels = []
-        self.page.commit()
+        self.page.commit(subscribe=subscribe)
         g.spam_checker.check(title + u'\n' + text, artifact=self.page,
                              user=c.user, content_type='wiki')
         g.director.create_activity(c.user, activity_verb, self.page,