mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-01 15:31:16 +00:00
[#1711] limit number of members that get sent down with group, limit profile
fields sent down
This commit is contained in:
parent
74e4ef0414
commit
65b18f3af1
2 changed files with 37 additions and 41 deletions
|
|
@ -105,28 +105,19 @@ api.get = function(req, res) {
|
|||
var gid = req.params.gid;
|
||||
|
||||
// This will be called for the header, we need extra members' details than usuals
|
||||
if (gid == 'party') {
|
||||
Group.findOne({type: 'party', members: {'$in': [user._id]}})
|
||||
.populate('members', partyFields)
|
||||
.populate('invites', nameFields)
|
||||
.populate('challenges', challengeFields)
|
||||
.exec(function(err, group){
|
||||
if (err) return res.json(500,{err:err});
|
||||
res.json(group);
|
||||
});
|
||||
} else {
|
||||
Group.findById(gid)
|
||||
.populate('members', partyFields)
|
||||
.populate('invites', nameFields)
|
||||
.populate('challenges', challengeFields)
|
||||
.exec(function(err, group){
|
||||
if ( (group.type == 'guild' && group.privacy == 'private') || group.type == 'party') {
|
||||
if(!_.find(group.members, {_id: user._id}))
|
||||
return res.json(401, {err: "You don't have access to this group"});
|
||||
}
|
||||
res.json(group);
|
||||
});
|
||||
}
|
||||
var q = (gid == 'party') ?
|
||||
Group.findOne({type: 'party', members: {'$in': [user._id]}}).populate('members', partyFields) :
|
||||
Group.findById(gid).populate({path: 'members', select: nameFields, options: {limit: 15} });
|
||||
|
||||
q.populate('invites', nameFields)
|
||||
.populate('challenges', challengeFields)
|
||||
.exec(function(err, group){
|
||||
if ( (group.type == 'guild' && group.privacy == 'private') || (group.type == 'party' && gid != 'party')) {
|
||||
if(!_.find(group.members, {_id: user._id}))
|
||||
return res.json(401, {err: "You don't have access to this group"});
|
||||
}
|
||||
res.json(group);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,26 @@ a.pull-right.gem-wallet(popover-trigger='mouseenter', popover-title='Guild Bank'
|
|||
li(ng-repeat='website in group.websites')
|
||||
a(target='_blank', ng-href='{{website}}') {{website}}
|
||||
|
||||
// ------ Information -------
|
||||
// ------ Challenges -------
|
||||
.modal(style='position: relative;top: auto;left: auto;right: auto;margin: 0 auto 20px;z-index: 1;max-width: 100%;')
|
||||
.modal-header
|
||||
h3
|
||||
| Challenges
|
||||
a.pull-right(target='_blank', href='https://trello.com/card/challenges-individual-party-guild-public/50e5d3684fe3a7266b0036d6/58')
|
||||
i.icon-question-sign
|
||||
.modal-body
|
||||
div(ng-if='group.challenges.length > 0')
|
||||
table.table.table-striped
|
||||
tr(ng-repeat='challenge in group.challenges')
|
||||
td
|
||||
a(ui-sref='options.social.challenges.detail({cid:challenge._id})') {{challenge.name}}
|
||||
p.
|
||||
Visit the <span class=label><i class=icon-bullhorn></i> Challenges</span> for more information.
|
||||
div(ng-if='group.challenges.length == 0')
|
||||
p.
|
||||
No challenges yet, visit the <span class=label><i class=icon-bullhorn></i> Challenges</span> tab to create one.
|
||||
|
||||
// ------ Members -------
|
||||
.modal(style='position: relative;top: auto;left: auto;right: auto;margin: 0 auto 20px;z-index: 1;max-width: 100%;')
|
||||
.modal-header
|
||||
h3 Members
|
||||
|
|
@ -62,7 +81,10 @@ a.pull-right.gem-wallet(popover-trigger='mouseenter', popover-title='Guild Bank'
|
|||
a
|
||||
span(ng-class='{"badge badge-info": group.leader==member._id}', ng-click='clickMember(member._id, true)')
|
||||
| {{member.profile.name}}
|
||||
td ({{member._id}})
|
||||
tr(ng-if='group.memberCount > group.members.length')
|
||||
td.
|
||||
<span class='badge'>{{group.memberCount - group.members.length}} more members</span>
|
||||
|
||||
h4(ng-show='group.invites.length > 0') Invited
|
||||
table.table.table-striped
|
||||
tr(ng-repeat='invite in group.invites')
|
||||
|
|
@ -82,23 +104,6 @@ a.pull-right.gem-wallet(popover-trigger='mouseenter', popover-title='Guild Bank'
|
|||
input.option-content(type='text', placeholder='User Id', ng-model='group.invitee')
|
||||
input.btn(type='submit', value='Invite')
|
||||
|
||||
.modal(style='position: relative;top: auto;left: auto;right: auto;margin: 0 auto 20px;z-index: 1;max-width: 100%;')
|
||||
.modal-header
|
||||
h3
|
||||
| Challenges
|
||||
a.pull-right(target='_blank', href='https://trello.com/card/challenges-individual-party-guild-public/50e5d3684fe3a7266b0036d6/58')
|
||||
i.icon-question-sign
|
||||
.modal-body
|
||||
div(ng-if='group.challenges')
|
||||
table.table.table-striped
|
||||
tr(ng-repeat='challenge in group.challenges')
|
||||
td
|
||||
a(ui-sref='options.social.challenges.detail({cid:challenge._id})') {{challenge.name}}
|
||||
p.
|
||||
Visit the <span class=label><i class=icon-bullhorn></i> Challenges</span> for more information.
|
||||
div(ng-if='!group.challenges')
|
||||
p.
|
||||
No challenges yet, visit the <span class=label><i class=icon-bullhorn></i> Challenges</span> tab to create one.
|
||||
|
||||
a.btn.btn-danger(data-id='{{group.id}}', ng-click='leave(group)') Leave
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue