Decouple clan type from dashboard details

Adding dashboardType field, private clans automatically set this to
‘premium’.
This commit is contained in:
Matt Lott 2015-04-20 14:04:22 -07:00
parent 45c070209b
commit f80a73ae9b
4 changed files with 6 additions and 2 deletions

View file

@ -9,7 +9,8 @@ _.extend ClanSchema.properties,
description: {type: 'string'} description: {type: 'string'}
members: c.array {title: 'Members'}, c.objectId() members: c.array {title: 'Members'}, c.objectId()
ownerID: c.objectId() ownerID: c.objectId()
type: {type: 'string', 'enum': ['public', 'private']} type: {type: 'string', 'enum': ['public', 'private'], description: 'Controls clan general visibility.'}
dashboardType: {type: 'string', 'enum': ['basic', 'premium']}
c.extendBasicProperties ClanSchema, 'Clan' c.extendBasicProperties ClanSchema, 'Clan'

View file

@ -75,7 +75,7 @@ block content
if members if members
h3 Heroes (#{members.length}) h3 Heroes (#{members.length})
if clan.get('type') === 'private' if clan.get('dashboardType') === 'premium'
table.table.table-condensed table.table.table-condensed
thead thead
tr tr

View file

@ -35,6 +35,7 @@ ClanHandler = class ClanHandler extends Handler
instance = super(req) instance = super(req)
instance.set 'ownerID', req.user._id instance.set 'ownerID', req.user._id
instance.set 'members', [req.user._id] instance.set 'members', [req.user._id]
instance.set 'dashboardType', 'premium' if req.body?.type is 'private'
instance instance
delete: (req, res, clanID) -> delete: (req, res, clanID) ->

View file

@ -23,12 +23,14 @@ describe 'Clans', ->
expect(body.type).toEqual(type) expect(body.type).toEqual(type)
expect(body.name).toEqual(name) expect(body.name).toEqual(name)
expect(body.description).toEqual(description) if description? expect(body.description).toEqual(description) if description?
expect(body.dashboardType).toEqual('premium') if type is 'private'
expect(body.members?.length).toEqual(1) expect(body.members?.length).toEqual(1)
expect(body.members?[0]).toEqual(user.id) expect(body.members?[0]).toEqual(user.id)
Clan.findById body._id, (err, clan) -> Clan.findById body._id, (err, clan) ->
expect(clan.get('type')).toEqual(type) expect(clan.get('type')).toEqual(type)
expect(clan.get('name')).toEqual(name) expect(clan.get('name')).toEqual(name)
expect(clan.get('description')).toEqual(description) if description? expect(clan.get('description')).toEqual(description) if description?
expect(clan.get('dashboardType')).toEqual('premium') if type is 'private'
expect(clan.get('members')?.length).toEqual(1) expect(clan.get('members')?.length).toEqual(1)
expect(clan.get('members')?[0]).toEqual(user._id) expect(clan.get('members')?[0]).toEqual(user._id)
User.findById user.id, (err, user) -> User.findById user.id, (err, user) ->