Ejemplo n.º 1
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.º 2
0
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'),
        })
Ejemplo n.º 3
0
 def commit(self):
     if self.id == 'newscener':
         releaser = Releaser(name=self.name, is_group=False, updated_at=datetime.datetime.now())
         releaser.save()
         self.id = releaser.primary_nick.id
         return releaser.primary_nick
     elif self.id == 'newgroup':
         releaser = Releaser(name=self.name, is_group=True, updated_at=datetime.datetime.now())
         releaser.save()
         self.id = releaser.primary_nick.id
         return releaser.primary_nick
     else:
         try:
             return Nick.objects.get(id=self.id)
         except Nick.DoesNotExist:
             raise NickSelection.FailedToResolve("Tried to match the name '#{self.name}' to nick ID #{self.id} which does not exist")
Ejemplo n.º 4
0
	def commit(self):
		if self.id == 'newscener':
			releaser = Releaser(name=self.name, is_group=False, updated_at=datetime.datetime.now())
			releaser.save()
			self.id = releaser.primary_nick.id
			return releaser.primary_nick
		elif self.id == 'newgroup':
			releaser = Releaser(name=self.name, is_group=True, updated_at=datetime.datetime.now())
			releaser.save()
			self.id = releaser.primary_nick.id
			return releaser.primary_nick
		else:
			try:
				return Nick.objects.get(id=self.id)
			except Nick.DoesNotExist:
				raise NickSelection.FailedToResolve("Tried to match the name '#{self.name}' to nick ID #{self.id} which does not exist")
Ejemplo n.º 5
0
 def test_asciified_real_name(self):
     gasman = Releaser(name="Gasman", first_name="Bjørn", surname="Westcott")
     self.assertEqual(gasman.asciified_real_name, "Bjorn Westcott")
Ejemplo n.º 6
0
 def test_no_name(self):
     gasman = Releaser(name="Gasman")
     self.assertEqual(gasman.real_name, None)
Ejemplo n.º 7
0
 def test_surname_only(self):
     gasman = Releaser(name="Gasman", surname="Westcott")
     self.assertEqual(gasman.real_name, "Westcott")
Ejemplo n.º 8
0
 def test_first_name_only(self):
     gasman = Releaser(name="Gasman", first_name="Matt")
     self.assertEqual(gasman.real_name, "Matt")
Ejemplo n.º 9
0
 def test_full_name(self):
     gasman = Releaser(name="Gasman", first_name="Matt", surname="Westcott")
     self.assertEqual(gasman.real_name, "Matt Westcott")