Просмотр исходного кода

BugFix: populate Page.grantedGroup to show

Yuki Takei 7 лет назад
Родитель
Сommit
88db623299

+ 9 - 5
src/server/models/page.js

@@ -78,11 +78,12 @@ const addSlashOfEnd = (path) => {
  */
 const populateDataToShowRevision = (page, userPublicFields) => {
   return page
-    .populate({path: 'lastUpdateUser', model: 'User', select: userPublicFields})
-    .populate({path: 'creator', model: 'User', select: userPublicFields})
-    .populate({path: 'revision', model: 'Revision', populate: {
+    .populate({ path: 'lastUpdateUser', model: 'User', select: userPublicFields })
+    .populate({ path: 'creator', model: 'User', select: userPublicFields })
+    .populate({ path: 'grantedGroup', model: 'UserGroup' })
+    .populate({ path: 'revision', model: 'Revision', populate: {
       path: 'author', model: 'User', select: userPublicFields
-    }});
+    } });
 };
 
 
@@ -811,7 +812,10 @@ module.exports = function(crowi) {
     const criteria = { redirectTo: null };
 
     return this.find(criteria)
-      .populate([{ path: 'creator', model: 'User' }, { path: 'revision', model: 'Revision' }])
+      .populate([
+        { path: 'creator', model: 'User' },
+        { path: 'revision', model: 'Revision' },
+      ])
       .lean()
       .cursor();
   };

+ 2 - 2
src/server/views/_form.html

@@ -17,8 +17,8 @@
 
   <div id="save-page-controls"
     data-grant="{{ page.grant }}"
-    data-grant-group="{{ pageRelatedGroup._id.toString() }}"
-    data-grant-group-name="{{ pageRelatedGroup.name }}">
+    data-grant-group="{{ page.grantedGroup._id.toString() }}"
+    data-grant-group-name="{{ page.grantedGroup.name }}">
   </div>
 
 </div>

+ 1 - 1
src/server/views/widget/page_alerts.html

@@ -7,7 +7,7 @@
       {% elseif page.grant == 4 %}
         <i class="icon-fw icon-lock"></i><strong>{{ consts.pageGrants[page.grant] }}</strong> ({{ t('Browsing of this page is restricted') }})
       {% elseif page.grant == 5 %}
-        <i class="icon-fw icon-organization"></i><strong>'{{ pageRelatedGroup.name | preventXss }}' only</strong> ({{ t('Browsing of this page is restricted') }})
+        <i class="icon-fw icon-organization"></i><strong>'{{ page.grantedGroup.name | preventXss }}' only</strong> ({{ t('Browsing of this page is restricted') }})
       {% endif %}
       </p>
     {% endif %}