예제 #1
0
 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())
예제 #2
0
    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)
예제 #3
0
	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)
예제 #4
0
파일: groups.py 프로젝트: rdavydov/demozoo
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'),
        })
예제 #5
0
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'),
        })
예제 #6
0
파일: groups.py 프로젝트: rdavydov/demozoo
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'),
	})
예제 #7
0
    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)