Esempio n. 1
0
def create_organizer_set(auto_create_user_set=False):
    """Create organizers set to test.

    Args:
    auto_create_user_set -- flag tindicating that create_user_set function must be executed

    Precondition:
    create_user_set

    Postcondition:
    Two Organizers created associated to users organizer01, and organizer02.
    Not events association.
    """
    if auto_create_user_set:
        create_user_set()

    set_current_user(User.objects.get(username="******"))

    Organizer.objects.bulk_create([
        Organizer(user=User.objects.get(username="******"),
                  first_name="Organizer01"),
        Organizer(user=User.objects.get(username="******"),
                  first_name="Organizer02"),
        Organizer(user=User.objects.get(username="******"),
                  first_name="Organizer03")
    ])
Esempio n. 2
0
def organizers(request):
    if request.method == "GET":  # Opening the page for the first time to display the head list
        events = Event.objects.filter(
            open=True)  # only show currently open events
        # events = Event.objects.filter()  # test
        roles = Role.objects.all()
        organizers = Organizer.objects.all()
        context = {'events': events, 'roles': roles, 'organizers': organizers}
        return render(request, "events/organizers.html", context)
    else:  # adding a new head
        name = request.POST['name']
        event = Event.objects.get(id=request.POST['eventid'])
        role = Role.objects.get(id=request.POST['roleid'])
        try:
            head = Head.objects.get(user=request.user)
        except:
            return render(request, "events/one_organizer.html",
                          {'organizer': "ERROR no head"})
        try:
            organizer = Organizer(event=event, name=name, role=role, head=head)
            organizer.save()
        except:
            return render(request, "events/one_organizer.html",
                          {'organizer': "ERROR can't save"})
        return render(request, "events/one_organizer.html",
                      {'organizer': organizer})
Esempio n. 3
0
 def test_email_url(self):
     """Comprueba que el email sea una email válido."""
     organizer = Organizer(
         name="Lugar 1",
         email="No es un email",
     )
     with self.assertRaisesRegex(ValidationError, "(email)"):
         organizer.full_clean()
Esempio n. 4
0
 def test_website_url(self):
     """Comprueba que el website sea una URL."""
     organizer = Organizer(
         name="Lugar 1",
         website="No es una URL",
     )
     with self.assertRaisesRegex(ValidationError, "(website).*(URL)"):
         organizer.full_clean()
Esempio n. 5
0
 def test_name_length(self):
     """Prueba la longitud del nombre."""
     organizer = Organizer(
         name="Lorem ipsum dolor sit amet, consectetuer adipiscing elit "\
             "aenean commodo ligula eget dolor"
     )
     with self.assertRaisesRegex(ValidationError, "(name).*(80)"):
         organizer.full_clean()
Esempio n. 6
0
 def test_phone_length(self):
     """Comprueba la longitud del teléfono."""
     organizer = Organizer(name="Organizador 1",
                           phone="Lorem ipsum dolor si")
     with self.assertRaisesRegex(ValidationError, "(phone).*(18)"):
         organizer.full_clean()