Ejemplo n.º 1
0
	def test_create(self):
		form = CreateScenerForm({
			'name': 'Factor6',
			'nick_variant_list': 'Factor 6, F6'
		})
		self.assertTrue(form.is_valid())
		form.save()

		releaser = Releaser.objects.get(name='Factor6')
		self.assertFalse(releaser.is_group)

		self.assertEqual(releaser.primary_nick.name, 'Factor6')

		nick_variants = [variant.name for variant in releaser.primary_nick.variants.all()]
		self.assertIn('Factor6', nick_variants)
		self.assertIn('Factor 6', nick_variants)
		self.assertIn('F6', nick_variants)

		form.log_creation(self.user)
		log_entry = Edit.objects.get(
			action_type='create_scener',
			focus_content_type=ContentType.objects.get_for_model(Releaser),
			focus_object_id=releaser.id
		)
		self.assertEqual(log_entry.user, self.user)
Ejemplo n.º 2
0
    def test_create(self):
        form = CreateScenerForm({
            'name': 'Factor6',
            'nick_variant_list': 'Factor 6, F6'
        })
        self.assertTrue(form.is_valid())
        form.save()

        releaser = Releaser.objects.get(name='Factor6')
        self.assertFalse(releaser.is_group)

        self.assertEqual(releaser.primary_nick.name, 'Factor6')

        nick_variants = [
            variant.name for variant in releaser.primary_nick.variants.all()
        ]
        self.assertIn('Factor6', nick_variants)
        self.assertIn('Factor 6', nick_variants)
        self.assertIn('F6', nick_variants)

        form.log_creation(self.user)
        log_entry = Edit.objects.get(
            action_type='create_scener',
            focus_content_type=ContentType.objects.get_for_model(Releaser),
            focus_object_id=releaser.id)
        self.assertEqual(log_entry.user, self.user)
Ejemplo n.º 3
0
def create(request):
    if request.method == 'POST':
        form = CreateScenerForm(request.POST)
        if form.is_valid():
            scener = form.save()
            form.log_creation(request.user)
            return HttpResponseRedirect(scener.get_absolute_edit_url())
    else:
        form = CreateScenerForm()

    return render(request, 'shared/simple_form.html', {
        'form': form,
        'html_title': "New scener",
        'title': "New scener",
        'action_url': reverse('new_scener'),
    })
Ejemplo n.º 4
0
def create(request):
	if request.method == 'POST':
		form = CreateScenerForm(request.POST)
		if form.is_valid():
			scener = form.save()
			form.log_creation(request.user)
			return HttpResponseRedirect(scener.get_absolute_edit_url())
	else:
		form = CreateScenerForm()

	return render(request, 'shared/simple_form.html', {
		'form': form,
		'html_title': "New scener",
		'title': "New scener",
		'action_url': reverse('new_scener'),
	})
Ejemplo n.º 5
0
def create(request):
	if request.method == 'POST':
		scener = Releaser(is_group=False, updated_at=datetime.datetime.now())
		form = CreateScenerForm(request.POST, instance=scener)
		if form.is_valid():
			form.save()
			form.log_creation(request.user)
			return HttpResponseRedirect(scener.get_absolute_edit_url())
	else:
		form = CreateScenerForm()

	return render(request, 'shared/simple_form.html', {
		'form': form,
		'html_title': "New scener",
		'title': "New scener",
		'action_url': reverse('new_scener'),
	})
Ejemplo n.º 6
0
def create(request):
    if request.method == 'POST':
        scener = Releaser(is_group=False, updated_at=datetime.datetime.now())
        form = CreateScenerForm(request.POST, instance=scener)
        if form.is_valid():
            form.save()
            form.log_creation(request.user)
            return HttpResponseRedirect(scener.get_absolute_edit_url())
    else:
        form = CreateScenerForm()

    return render(
        request, 'shared/simple_form.html', {
            'form': form,
            'html_title': "New scener",
            'title': "New scener",
            'action_url': reverse('new_scener'),
        })
Ejemplo n.º 7
0
    def test_create(self):
        form = CreateScenerForm({"name": "Factor6", "nick_variant_list": "Factor 6, F6"})
        self.assertTrue(form.is_valid())
        form.save()

        releaser = Releaser.objects.get(name="Factor6")
        self.assertFalse(releaser.is_group)

        self.assertEqual(releaser.primary_nick.name, "Factor6")

        nick_variants = [variant.name for variant in releaser.primary_nick.variants.all()]
        self.assertIn("Factor6", nick_variants)
        self.assertIn("Factor 6", nick_variants)
        self.assertIn("F6", nick_variants)

        form.log_creation(self.user)
        log_entry = Edit.objects.get(
            action_type="create_scener",
            focus_content_type=ContentType.objects.get_for_model(Releaser),
            focus_object_id=releaser.id,
        )
        self.assertEqual(log_entry.user, self.user)