コード例 #1
0
 def get_context_data(self, *args, **kwargs):
     ctx = super(TeamDetailView, self).get_context_data(*args, **kwargs)
     ctx.update({
         'form_member_add':
         forms.TeamMemberAddForm(team=self.object),
     })
     return ctx
コード例 #2
0
ファイル: test_forms.py プロジェクト: tranarthur/localshop
    def test_duplicate(self):
        user = UserFactory()
        team = TeamFactory()
        TeamMemberFactory(user=user, team=team, role='owner')

        data = {
            'user': user.pk,
            'role': 'owner',
        }
        form = forms.TeamMemberAddForm(data=data, team=team)
        assert not form.is_valid()
コード例 #3
0
ファイル: test_forms.py プロジェクト: tranarthur/localshop
    def test_save(self):
        user = UserFactory()
        team = TeamFactory()

        data = {
            'user': user.pk,
            'role': 'owner',
        }
        form = forms.TeamMemberAddForm(data=data, team=team)
        assert form.is_valid()

        form.save()
        assert team.users.count() == 1

        member = team.members.first()
        assert member.user == user
        assert member.role == 'owner'