def test_no_commit(self): form = CreateGroupForm({ 'name': 'Poo-Brain', 'abbreviation': 'PB', 'nick_variant_list': 'Poo Brain, PooBrain' }) self.assertTrue(form.is_valid()) form.save(commit=False) self.assertFalse(Releaser.objects.filter(name='Poo-Brain').exists())
def test_create(self): form = CreateGroupForm({ 'name': 'Poo-Brain', 'abbreviation': 'PB', 'nick_variant_list': 'Poo Brain, PooBrain' }) self.assertTrue(form.is_valid()) form.save() releaser = Releaser.objects.get(name='Poo-Brain') self.assertTrue(releaser.abbreviation, 'PB') self.assertTrue(releaser.is_group) self.assertEqual(releaser.primary_nick.name, 'Poo-Brain') nick_variants = [ variant.name for variant in releaser.primary_nick.variants.all() ] self.assertIn('Poo-Brain', nick_variants) self.assertIn('Poo Brain', nick_variants) self.assertIn('PooBrain', nick_variants) form.log_creation(self.user) log_entry = Edit.objects.get( action_type='create_group', focus_content_type=ContentType.objects.get_for_model(Releaser), focus_object_id=releaser.id) self.assertEqual(log_entry.user, self.user)
def test_create(self): form = CreateGroupForm({ 'name': 'Poo-Brain', 'abbreviation': 'PB', 'nick_variant_list': 'Poo Brain, PooBrain' }) self.assertTrue(form.is_valid()) form.save() releaser = Releaser.objects.get(name='Poo-Brain') self.assertTrue(releaser.abbreviation, 'PB') self.assertTrue(releaser.is_group) self.assertEqual(releaser.primary_nick.name, 'Poo-Brain') nick_variants = [variant.name for variant in releaser.primary_nick.variants.all()] self.assertIn('Poo-Brain', nick_variants) self.assertIn('Poo Brain', nick_variants) self.assertIn('PooBrain', nick_variants) form.log_creation(self.user) log_entry = Edit.objects.get( action_type='create_group', focus_content_type=ContentType.objects.get_for_model(Releaser), focus_object_id=releaser.id ) self.assertEqual(log_entry.user, self.user)
def create(request): if request.method == 'POST': group = Releaser(is_group=True, updated_at=datetime.datetime.now()) form = CreateGroupForm(request.POST, instance=group) if form.is_valid(): form.save() form.log_creation(request.user) return HttpResponseRedirect(group.get_absolute_edit_url()) else: form = CreateGroupForm() return render( request, 'shared/simple_form.html', { 'form': form, 'title': "New group", 'html_title': "New group", 'action_url': reverse('new_group'), })
def create(request): if request.method == 'POST': form = CreateGroupForm(request.POST) if form.is_valid(): group = form.save() form.log_creation(request.user) return HttpResponseRedirect(group.get_absolute_url()) else: form = CreateGroupForm() return render( request, 'shared/simple_form.html', { 'form': form, 'title': "New group", 'html_title': "New group", 'action_url': reverse('new_group'), })
def create(request): if request.method == 'POST': group = Releaser(is_group=True, updated_at=datetime.datetime.now()) form = CreateGroupForm(request.POST, instance=group) if form.is_valid(): form.save() form.log_creation(request.user) return HttpResponseRedirect(group.get_absolute_edit_url()) else: form = CreateGroupForm() return render(request, 'shared/simple_form.html', { 'form': form, 'title': "New group", 'html_title': "New group", 'action_url': reverse('new_group'), })
def test_create(self): form = CreateGroupForm({"name": "Poo-Brain", "abbreviation": "PB", "nick_variant_list": "Poo Brain, PooBrain"}) self.assertTrue(form.is_valid()) form.save() releaser = Releaser.objects.get(name="Poo-Brain") self.assertTrue(releaser.abbreviation, "PB") self.assertTrue(releaser.is_group) self.assertEqual(releaser.primary_nick.name, "Poo-Brain") nick_variants = [variant.name for variant in releaser.primary_nick.variants.all()] self.assertIn("Poo-Brain", nick_variants) self.assertIn("Poo Brain", nick_variants) self.assertIn("PooBrain", nick_variants) form.log_creation(self.user) log_entry = Edit.objects.get( action_type="create_group", focus_content_type=ContentType.objects.get_for_model(Releaser), focus_object_id=releaser.id, ) self.assertEqual(log_entry.user, self.user)