def add_email_tag(entryID, tag): emailID = emailTable.get_email_id_for_email(entryID) print('emailID is {0}'.format(emailID)) tagID = tagTable.get_tag_id_for_tag(tag) if (tagID=='?'): return util.insert_rejected('tag {0} does not exist'.format(tag)) if (emailID=='?'): return util.insert_rejected('email {0} does not exist'.format(entryID)) print('tagID is {0}'.format(tagID)) query = "INSERT INTO EmailTags (EmailID, TagID) VALUES ('{0}','{1}');".format(emailID, tagID) return db.insert_and_get_id(query, 'EmailTags')
def add_person_tag(person, tag): personID = personTable.get_person_id_for_person(person) print('personID is {0}'.format(personID)) tagID = tagTable.get_tag_id_for_tag(tag) if (tagID == '?'): return util.insert_rejected('tag {0} does not exist'.format(tag)) if (personID == '?'): return util.insert_rejected('person {0} does not exist'.format(person)) print('tagID is {0}'.format(tagID)) query = "INSERT INTO PersonTags (PersonID, TagID) VALUES ('{0}','{1}');".format( personID, tagID) return db.insert_and_get_id(query, 'PersonTags')
def add_resource_tag(type, name, tag): resourceID = resourceTable.get_resource_id(type, name) print('resourceID is {0}'.format(resourceID)) tagID = tagTable.get_tag_id_for_tag(tag) if (tagID == '?'): return util.insert_rejected('tag {0} does not exist'.format(tag)) if (resourceID == '?'): return util.insert_rejected('resource {0} {1} does not exist'.format( type, name)) print('tagID is {0}'.format(tagID)) query = "INSERT INTO ResourceTags (ResourceID, TagID) VALUES ('{0}','{1}');".format( resourceID, tagID) return db.insert_and_get_id(query, 'ResourceTags')
def tag_email(): entryID = request.args.get('entryID') tag = request.args.get('tag') if emailTagTable.is_email_tag_in_db(entryID, tag): return util.insert_rejected('email {0} already tagged with {1}'.format(entryID, tag)) else: return emailTagTable.add_email_tag(entryID, tag)
def tag_person(): tag = request.args.get('tag') person = request.args.get('name') if personTagTable.is_person_tag_in_db(person, tag): return util.insert_rejected('person {0} already tagged with {1}'.format(person, tag)) else: return personTagTable.add_person_tag(person, tag)
def add_email(): conversationID = request.args.get('conversationID') entryID = request.args.get('entryID') if emailTable.is_email_in_db(conversationID, entryID): return util.insert_rejected('emails entry {0} already exists'.format(entryID)) else: return emailTable.add_email(conversationID, entryID)
def add_resource(): resource_type = request.args.get('resourceType') name = request.args.get('name') if resourceTable.is_resource_in_db(resource_type, name): return util.insert_rejected('resource {0} of type {1} already exists'.format(name, resource_type)) else: return resourceTable.add_resource(resource_type, name)
def tag_resource(): type = request.args.get('type') name = request.args.get('name') tag = request.args.get('tag') if resourceTagTable.is_resource_tag_in_db(type, name, tag): return util.insert_rejected('resource {0} {1} already tagged with {2}'.format(type, name, tag)) else: return resourceTagTable.add_resource_tag(type, name, tag)
def add_person(): name = request.args.get('name') if personTable.is_person_in_db(name): return util.insert_rejected('person {0} already exists'.format(name)) else: return personTable.add_person(name)
def add_tag(): tag = request.args.get('tag') if tagTable.is_tag_in_db(tag): return util.insert_rejected('tag {0} already exists'.format(tag)) else: return tagTable.add_tag(tag)