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 delete(): recycleId = Recycle.create("Company account deleted.") company_users = meta.Session.query(Manager).filter_by(companyid = request.environ.get('COMPANY_ID') ) company_users.update({Manager.deleted: recycleId}) for user in company_users: if user.username: request.environ['authkit.users'].user_set_group(user.username, 'deleted') else: meta.Session.delete(user) meta.Session.query(Company).filter_by(id = request.environ.get('COMPANY_ID') )\ .update({Company.deleted: recycleId}) meta.Session.commit() session.save()
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()