def update(**kwargs): contact = Contact.get(kwargs['id']) for key in kwargs: contact.__setattr__(key, kwargs[key]) meta.Session.commit() session.save() contact_type = Contact_type.get(kwargs['typeid']) index_update = IndexUpdate() index_update.updateItem('contact', kwargs['id']) index_update.updateData(kwargs['label'] + ' ' + str(kwargs['description']) + ' ' + str(contact_type.label)) index_update.update()
def delete(id): contact = Contact.get(id) recycleId = Recycle.create("Contact deleted: {0}".format(contact.label)) contact.deleted = recycleId meta.Session.commit() session.save() index_update = IndexUpdate() index_update.updateItem('contact', id) index_update.updateTerm('deleted', 0, recycleId) index_update.update()
def save(**kwargs): property = Property.get_property(kwargs['id']) for key in kwargs: property.__setattr__(key, kwargs[key]) meta.Session.commit() session.save() text = ' '.join([str(property.name), str(property.name), str(property.address), str(property.city), str(property.zip)]) index_update = IndexUpdate() index_update.updateItem('property', property.id) index_update.moreData(text) index_update.update()
def update(**kwargs): tenant = Tenant.get(kwargs['id']) for key in kwargs: tenant.__setattr__(key, kwargs[key]) meta.Session.commit() session.save() text = ' '.join([tenant.first_name, tenant.last_name]) index_update = IndexUpdate() index_update.updateItem('tenant', kwargs['id']) index_update.updateData(text) index_update.update()
def rename(newlabel, unitid): from rentfox.model.property import Property unit = meta.Session.query(Unit).filter(Unit.deleted==None).filter_by(id=unitid).first() unit.label = newlabel meta.Session.commit() session.save() # update index property = Property.get_property(unit.propertyid) text = ' '.join([str(newlabel), str(newlabel), str(newlabel), str(property.name), str(property.address)]) index_update = IndexUpdate() index_update.updateItem('unit', unitid) index_update.updateData(text) index_update.update()
def delete(unitid): from rentfox.model.recycle import Recycle from rentfox.model.property import Property from rentfox.model.lease import Lease unit = meta.Session.query(Unit).filter_by(id=unitid).first() property_name = Property.get_name_by_id(unit.propertyid) recycleId = Recycle.create("Unit {0} deleted from {1}".format(unit.label, property_name)) unit.deleted = recycleId Lease.deleteByUnitId(unitid, recycleId) meta.Session.commit() session.save() index_update = IndexUpdate() index_update.updateItem('unit', unitid) index_update.updateTerm('deleted', 0, recycleId) index_update.update()
def delete(id): from rentfox.model.contact import Contact contact_type = Contact_type.get(id) recycleId = Recycle.create("Contacts deleted from {0}.".format(contact_type.label)) contacts = meta.Session.query(Contact).filter_by(typeid=id).filter(Contact.deleted==None).all() index_update = IndexUpdate() for contact in contacts: contact.deleted = recycleId index_update.updateItem('contact', contact.id) index_update.updateTerm('deleted', 0, recycleId) index_update.update() contact_type.deleted = recycleId meta.Session.commit() session.save()
def delete(propertyid): from rentfox.model.pulse import Pulse from rentfox.model.lease import Lease from rentfox.model.contact_type import Contact_type property = Property.get_property(propertyid) recycleId = Recycle.create("Property deleted: {0}".format(property.name)) #set property, units, floorplans to deleted property.deleted = recycleId Unit.deleteByPropertyId(propertyid, recycleId) Floorplan.deleteByPropertyId(propertyid, recycleId) Lease.deleteByPropertyId(propertyid, recycleId) meta.Session.commit() session.save() index_update = IndexUpdate() index_update.updateItem('property', propertyid) index_update.updateTerm('deleted', 0, recycleId) index_update.update()
def delete_units(units, propertyid): from rentfox.model.property import Property from rentfox.model.recycle import Recycle from rentfox.model.lease import Lease count = 0 property_name = Property.get_name_by_id(propertyid) recycleId = Recycle.create("Units deleted from {0}".format(property_name)) index_update = IndexUpdate() if '-' in units: unitRange = units.split('-') start = unitRange[0] end = unitRange[1] # Special case: Allow for labels such as 12-B or C-2 to be deleted. if (start.isdigit() and end.isalpha())\ or (end.isdigit() and start.isalpha()): existingUnits = Unit.get_units_list(propertyid) if str(units) in existingUnits: unit = Unit.get_unit_with_propertyid(units, propertyid) unit.deleted = recycleId index_update.updateItem('unit', unit.id) index_update.updateTerm('deleted', 0, recycleId) index_update.update() Lease.deleteByUnitId(unit.id, recycleId) count += 1 else: existingUnits = Unit.get_units_list(propertyid) for unit in range(int(start), int(end) + 1): if str(unit) in existingUnits: unit = Unit.get_unit_with_propertyid(str(unit), propertyid) unit.deleted = recycleId index_update.updateItem('unit', unit.id) index_update.updateTerm('deleted', 0, recycleId) index_update.update() Lease.deleteByUnitId(unit.id, recycleId) count += 1 elif ',' in units: unitList = units.split(',') existingUnits = Unit.get_units_list(propertyid) for unit in unitList: if str(unit) in existingUnits: unit = Unit.get_unit_with_propertyid(str(unit), propertyid) unit.deleted = recycleId index_update.updateItem('unit', unit.id) index_update.updateTerm('deleted', 0, recycleId) index_update.update() Lease.deleteByUnitId(unit.id, recycleId) count += 1 else: unit = Unit.get_unit_with_propertyid(units, propertyid) unit.deleted = recycleId index_update.updateItem('unit', unit.id) index_update.updateTerm('deleted', 0, recycleId) index_update.update() Lease.deleteByUnitId(unit.id, recycleId) count += 1 if count == 0: Recycle.delete(recycleId) return False meta.Session.commit() session.save()