예제 #1
0
def createarea(request):
    form = CreateAreaForm()
    if request.method == 'POST':
        form = CreateAreaForm(request.POST)
        if form.is_valid():
            a = emod.Area()
            a.name = form.cleaned_data.get('name')
            a.description = form.cleaned_data.get('description')
            a.place_number = form.cleaned_data.get('place_number')
            a.event = form.cleaned_data.get('event')
            a.save()
            return HttpResponseRedirect(
                '/event/events.edit/{id}'.format(id=a.event.id))

    template_vars = {
        'form': form,
    }
    return dmp_render_to_response(request, 'events.createarea.html',
                                  template_vars)
예제 #2
0
파일: areas.py 프로젝트: dvnrsn/CHF
def create(request):
    '''Creates a areas'''
    form = CreateForm()
    if request.method == 'POST':  # just submitted the form
        form = CreateForm(request.POST)
        if form.is_valid():
            u = emod.Area()
            u.name = form.cleaned_data.get('name')
            u.description = form.cleaned_data.get('description')
            u.place_number = form.cleaned_data.get('place_number')
            u.event = emod.Event.objects.get(id=request.urlparams[0])
            u.save()
            return HttpResponseRedirect('/event/events.edit/' +
                                        request.urlparams[0])

    template_vars = {
        'form': form,
    }
    return dmp_render_to_response(request, 'areas.create.html', template_vars)
예제 #3
0
파일: initialize.py 프로젝트: dvnrsn/CHF
venues = []  # to save for use later
for i in range(1, 10):
    o = emod.Venue()
    o.name = 'Venue%i' % i
    o.address = 'Address %i' % i
    o.city = 'City%i' % i
    o.state = 'State%i' % i
    o.zip_code = 'ZipCode%i' % i
    o.save()
    print(o)
    venues.append(o)

# create the events
for i in range(1, 10):
    o = emod.Event()
    o.name = 'Event%i' % i
    o.description = 'Description of the event %i' % i
    o.start_date = datetime.datetime.now()
    o.end_date = datetime.datetime.now()
    o.venue = random.choice(venues)
    o.save()
    # add some areas to the event
    for j in range(1, 4):
        a = emod.Area()
        a.name = 'Area%i' % j
        a.description = 'Description of the area %i' % j
        a.place_number = i * j
        a.event = o
        a.save()
    print(o)