def create(request): params = {} form = AreasForm( initial={ 'name': '', 'description': '', 'placeNumber': '', 'coordinatingAgent': '', 'supervisingAgent': '', 'event': '' }) if request.method == 'POST': form = AreasForm(request.POST) if form.is_valid(): area = hmod.Area() area.name = form.cleaned_data['name'] area.description = form.cleaned_data['description'] area.placeNumber = form.cleaned_data['placeNumber'] area.coordinatingAgentID_id = form.cleaned_data[ 'coordinatingAgent'] area.supervisingAgentID_id = form.cleaned_data['supervisingAgent'] area.eventID_id = form.cleaned_data['event'] area.save() return HttpResponseRedirect('/homepage/areas/') params['form'] = form return templater.render_to_response(request, 'items_edit.html', params)
def create(request): area1 = hmod.Area() area1.name = 'New Area' area1.description = 'New Description' area1.place_number = 9999 # ... other field defaults area1.save() return HttpResponseRedirect('/homepage/areas.edit/{}/'.format(area1.photographablething_ptr_id))
def create(request): params = {} class areaEditForm(forms.Form): name = forms.CharField( required=True, max_length=100, widget=forms.TextInput(attrs={'class': 'form-control'})) description = forms.CharField( required=True, max_length=1000, widget=forms.TextInput(attrs={'class': 'form-control'})) place_number = forms.CharField( required=False, max_length=1000, widget=forms.TextInput(attrs={'class': 'form-control'})) coordinator_id = forms.CharField( required=True, max_length=1000, widget=forms.TextInput(attrs={'class': 'form-control'})) supervisor_id = forms.CharField( required=True, max_length=1000, widget=forms.TextInput(attrs={'class': 'form-control'})) event_id = forms.IntegerField( required=True, widget=forms.TextInput(attrs={'class': 'form-control'})) form = areaEditForm() if request.method == 'POST': form = areaEditForm(request.POST) if form.is_valid(): area = hmod.Area() area.name = form.cleaned_data['name'] area.description = form.cleaned_data['description'] area.place_number = form.cleaned_data['place_number'] area.coordinator_id = form.cleaned_data['coordinator_id'] area.supervisor_id = form.cleaned_data['supervisor_id'] area.event_id = form.cleaned_data['event_id'] area.save() return HttpResponseRedirect('/homepage/area.admin/') else: params[ 'error'] = "<p class='bg-danger'>All fields are required</p>" params['form'] = form return templater.render_to_response(request, 'area.edit.html', params) params['error'] = "" params['form'] = form return templater.render_to_response(request, 'area.edit.html', params)
def create(request): params = {} area = hmod.Area() area.name = '' area.description = '' area.save() return HttpResponseRedirect('/administrator/areas.edit/{}/'.format( area.id))
def create(request): area = hmod.Area() area.object_id = str(random.randint(1000001, 9999999)) area.name = 'Area Name' area.description = 'This is a description of the area' area.place_number = str(random.randint(10001, 99999)) area.save() return HttpResponseRedirect('/homepage/areas.edit/{}/'.format( area.object_id))
def create(request): if not request.user.is_authenticated(): return redirect('/homepage/login/?next=%s' % request.path) if not request.user.is_staff: return HttpResponseRedirect('/homepage/authentication') '''Creates a new area''' area = hmod.Area() area.name = '' area.description = '' area.place_number = '' # area.event = '' area.save() return HttpResponseRedirect('/homepage/areas.edit/{}/'.format(area.id))
rentedLineItem.discount_percent = data[7] rentedLineItem.fees_paid = data[8] rentedLineItem.wardrobe_item_ID = data[9] rentedLineItem.transaction_ID = data[10] rentedLineItem.save() for data in [ ['Old Timey Trail Hike', 'historical walk through the provo canyon', 1, hmod.Event.objects.get(id=1), hmod.User.objects.get(id=1), hmod.User.objects.get(id=2)], ['Old Timey baking adventure', 'a walk through of the daily process required for feeding oneself during colonial times', 1, hmod.Event.objects.get(id=1), hmod.User.objects.get(id=2), hmod.User.objects.get(id=3)], ['Old Timey arms display', 'a display of the progress of colonial weaponry through the time period', 1, hmod.Event.objects.get(id=2), hmod.User.objects.get(id=3), hmod.User.objects.get(id=2)], ]: area = hmod.Area() area.name = data[0] area.description = data[1] area.placeNumber = data[2] area.event_ID = data[3] area.coordinator_ID = data[4] area.supervisor_ID = data[5] area.save() for data in [ ['Colonial Knife', 'a dull, rusty knife', 22.50, 35.50, hmod.Area.objects.get(id=1)], ['Colonial Broom', 'an atrsy colonial broom', 22.50, 40.50, hmod.Area.objects.get(id=1)], ['Colonial Stool', 'a typical colonial stool', 52.50, 55.50, hmod.Area.objects.get(id=2)], ['Colonial spood', 'a spoon typical of the time period', 32.50, 35.50, hmod.Area.objects.get(id=3)],
'place_number': '4' }, { 'description': 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.', 'name': 'Candle Maker', 'place_number': '5' }, { 'description': 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.', 'name': 'Guest Services', 'place_number': '6' }, ]: d = hmod.Area() for k, v in data.items(): setattr(d, k, v) d.save() # populating data for products for data in [ { 'name': 'Cannonball', 'category': 'Weapons', 'current_price': '201.15', 'product_type': 'Mass Produced', 'producer_name': 'Colonial Heritage Foundation', 'quantity_on_hand': '40', 'date_made': '2015-03-06', 'order_form_name': 'Pittsburgh',
l.state = data[3] l.save() print(l) ############################### -AREAS- ############################### hmod.Area.objects.all().delete() #create new Area: name, description for data in [ ['Knead The Dough','Knead the dough before we start the cookin!'], ['Shooting Range','Safe area located on the far end of the park'], ['Pen Writing Station','Pen writing desks that lets us write'], ['Fake Village','Fake village located in the soutwest corner'], ]: ar = hmod.Area() ar.name = data[0] ar.description = data[1] ar.save() print(ar) #runs server ############################### -RUN SERVER- ############################### subprocess.call([sys.executable, "manage.py", "runserver"])
## Organizations: org1 = hmod.Organization() org1.given_name = "Colonial Heritage Foundation" org1.organization_type = "Non-profit Organization" org1.creation_date = "2007-01-09" org1.save() org2 = hmod.Organization() org2.given_name = "Brigham Young University" org2.organization_type = "Educational" org2.creation_date = "2001-01-01" org2.save() ## Areas: area1 = hmod.Area() area1.name = "Declaration Signing Room" area1.description = "A display of the room that the Declaration of Independence was signed in." area1.place_number = 1 area1.save() ## Events event1 = hmod.Event() event1.name = "Colonial Heritage Festival" event1.start_date = "2015-06-29" event1.end_date = "2015-07-11" event1.map_file = "image.png" event1.save() ## Rentals rental = hmod.Rental()
p.description = "delicious homemade bread" p.save() p = hmod.ProductSpecification() p.name = "Pic with Gove" p.price = 1.99 p.description = "Get a Picture with Gove Allen" p.save() p = hmod.ProductSpecification() p.name = "fake item1" p.price = 15.67 p.description = "test item description" p.save() a = hmod.Area() a.name = "area 1" a.description = "This is the 1st area" a.place_number = 1 a.save() a = hmod.Area() a.name = "area 2" a.description = "This is the 2nd area" a.place_number = 2 a.save() a = hmod.Area() a.name = "area 3" a.description = "This is the 3rd area" a.place_number = 3