def setUp(self):
     self.propertyDefaults = Property()
     self.testDict['propInfo'] = PropInfo(self.testPropInfo)
     self.testDict['address'] = Location(self.testLocation)
     self.testDict['contactName'] = Name(self.testName)
     self.testDict['contactInfo'] = Contact(self.testContact)
     self.testDict['rooms'] = [
         RoomType(self.testRoomType1),
         RoomType(self.testRoomType2)
     ]
     self.testDict['reviews'] = [Review(self.testReview)]
     self.propertyFromDict = Property(self.testDict)
     self.maxDiff = None
 def test_property_service_fetchTop10_returns_list_of_property_instances(
         self):
     result = self.propService.fetchTop10()
     first = result[0]
     # check to see if 1st result is of type Property
     expected = Property()
     actual = first
     self.assertEqual(type(expected), type(actual))
Ejemplo n.º 3
0
 def getPropertyFromForms(self):
     # get property form
     prop_form = self.forms['prop']
     # create data dictionary
     data = {
         'partnerKey': prop_form.cleaned_data.get('prop_partnerKey'),
         'propName': prop_form.cleaned_data.get('prop_propName'),
         'propInfo': PropInfo(self.getCleanDataByKey('info')),
         'address': Location(self.getCleanDataByKey('location')),
         'contactName': Name(self.getCleanDataByKey('name')),
         'contactInfo': Contact(self.getCleanDataByKey('contact')),
     }
     # create and return Property instance
     return Property(data)
Ejemplo n.º 4
0
def delProperty(request):

    # initialize vars
    propSvc = PropertyService(Config())
    prop = Property()
    rooms = []
    message = ''
    confirm = False
    prop_key = ''

    # check for delete confirmation
    if request.method == 'POST':
        # first check to see if property key was chosen
        if 'prop_propertyKey' in request.POST:
            prop_key = request.POST['prop_propertyKey']
            prop = propSvc.fetchByKey(prop_key)
            if prop:
                confirm = True
                message = 'Confirm property to delete'
        # else check to see if property key + delete confirm
        if 'del_confirm_yes' in request.POST and 'prop_key' in request.POST:
            prop_key = request.POST['prop_key']
            prop = propSvc.fetchByKey(prop_key)
            # proceed with delete
            if prop:
                if propSvc.deleteByKey(prop_key):
                    message = 'Property ' + prop.get(
                        'propName') + ' was successfully deleted'
                else:
                    message = 'Unable to delete property ' + prop.get(
                        'propName')
            else:
                message = 'Unable to delete property ' + prop.get('propName')

    # build master form
    info = prop.get('propInfo')
    context = {
        'choose_part_form': ChoosePartnerForm(),
        'message': message,
        'prop_name': prop.get('propName'),
        'prop_type': info.get('type'),
        'prop_des': info.get('description'),
        'prop_key': prop_key,
        'confirm': confirm,
    }
    # embed form in layout
    prop_master = render_to_string('property_list_del.html', context)
    page = render_to_string('layout.html', {'contents': prop_master})
    return HttpResponse(page)
Ejemplo n.º 5
0
 def assemble(self, doc):
     prop = Property(doc)
     if 'propInfo' in doc:
         prop['propInfo'] = PropInfo(doc['propInfo'])
     if 'address' in doc:
         prop['address'] = Location(doc['address'])
     if 'contactName' in doc:
         prop['contactName'] = Name(doc['contactName'])
     if 'contactInfo' in doc:
         prop['contactInfo'] = Contact(doc['contactInfo'])
     if 'rooms' in doc:
         prop['rooms'] = []
         for room in doc['rooms']:
             prop['rooms'].append(RoomType(room))
     if 'reviews' in doc:
         prop['reviews'] = []
         for review in doc['reviews']:
             prop['reviews'].append(Review(room))
     return prop
Ejemplo n.º 6
0
def listProp(request, prop_key=None):
    propSvc = PropertyService(Config())
    prop = Property()
    rooms = []
    message = ''
    if prop_key:
        prop = propSvc.fetchByKey(prop_key)
    # build master form
    info = prop.get('propInfo')
    context = {
        'message': message,
        'prop_name': prop.get('propName'),
        'prop_type': info.get('type'),
        'prop_des': info.get('description'),
        'prop_key': prop_key,
    }
    prop_master = render_to_string('property_list.html', context)
    # embed form in layout
    page = render_to_string('layout.html', {'contents': prop_master})
    return HttpResponse(page)