Example #1
0
 def test_event_create_invalid_dates(self):
     form_data = {
         'name': 'Intro to Python',
         'start_date': '2018-04-30',
         'finish_date': '2018-04-29',
         'owner': '1',
         'description': 'introduction to Python',
         'prerequisite': 'Nil',
         'period': 'period',
         'slug': 'Intro-to-Python'
     }
     form = EventForm(data=form_data)
     self.assertFalse(form.is_valid())
Example #2
0
 def test_event_create_invalid_name(self):
     form_data = {
         'name':
         'Name that exceeds 100 characters.........................'
         '................................................................',
         'start_date':
         '2018-04-30',
         'finish_date':
         '2018-04-29',
         'owner':
         '1',
         'description':
         'introduction to Python',
         'prerequisite':
         'Php :)',
         'period':
         'period',
         'slug':
         'Name-that-exceeds-100-characters.........................'
         '................................................................',
     }
     form = EventForm(data=form_data)
     self.assertFalse(form.is_valid())
Example #3
0
 def setUp(self):
     form_data = {
         'name': 'Intro to Python',
         'start_date': '2018-10-31',
         'finish_date': '2018-11-08',
         'owner': '1',
         'description': 'introduction to Python',
         'prerequisite': 'Nil',
         'period': 'period',
         'slug': 'Intro-to-Python'
     }
     self.owner = CustomUser.objects.create_superuser(username='******',
                                                      email='',
                                                      password='******')
     self.event = EventForm(data=form_data).save()
Example #4
0
def event_create(request):
    """
    Render and show an event creation form. The form allows for the creation of new events.
    Only staff members can access and see this page.

    Args:
        request: HTTP request header contents

    Returns:
        HTTP response containing the event creation form
    """
    if request.method == 'POST':
        event_form = EventForm(request.POST, prefix='event_form')
        if event_form.is_valid():
            event_form.save()
            return redirect('website:event_index')
    else:
        event_form = EventForm(prefix='event_form')

    context = {'event_form': event_form}
    return render(request, 'website/event_create.html', context)
Example #5
0
 def test_event_form(self):
     form = EventForm(data={
         'model': ['Event'],
         'fields': ['avihai', 27 / 7 / 92]
     })