【发布时间】:2017-07-31 06:39:02
【问题描述】:
我一直在将活动注册功能添加到我的 Apostrophe 网站中。我创建了一个新的“领导者”组,如果用户属于该组,则活动页面应显示一个包含当前注册人数/基本信息的表格:
{% for reg in data.piece.registrants %}
{% set count = count + reg.attendeeCount %}
<tr>
<td>{{reg._user.firstName}} {{reg._user.lastName}}</td>
<td>{{reg.attendeeCount}}</td>
</tr>
{% endfor %}
<tr class="total-registrant-row">
<td>Total</td>
<td></td>
<td></td>
<td>{{count}}</td>
我在撇号事件中添加了一个 Registrants 数组,它本身包含一个与用户的连接:
addFields: [
{
name: 'registrants',
label: 'Registrants',
type: 'array',
schema: [
{
name: '_user',
withType: 'apostrophe-user',
type: 'joinByOne',
idField: 'userId',
filters: {
// Fetch only basic information to show in table:
projection: {
id: 1,
username: 1,
firstName: 1,
lastName: 1,
email: 1
}
}
},
{
name: 'registrationDate',
label: 'Registration Date',
contextual: true,
type: 'string'
},
{
name: 'attendeeCount',
label: 'Total Attendees',
type: 'integer'
}
]
}
]
我注意到当我以管理员身份登录时,这可以正常工作,但如果我以领导组中的用户(不是管理员)身份登录,则会显示计数,但不会显示用户信息。我假设这是因为领导组无权获取任何用户。我将如何设置它,以便模板在这种情况下绕过权限,或授予领导者查看任何注册活动用户的信息的权限?
谢谢!
【问题讨论】:
标签: apostrophe-cms