Example #1
0
def citation_remove_project(ref, citation_id, project_id):
    """remove project from citation
    :param ref:Firebase
    :param citation_id:str
    :param project_id:str
    """
    citation_id = str(citation_id)
    project_id = str(project_id)
    if not ref.exists('citations', citation_id):
        ref.eprint("citation #{} does'nt exist".format(citation_id))
        return
    if not ref.exists('projects', project_id):
        ref.eprint("project #{} does'nt exist".format(project_id))
        return
    data = ref.get('citations/{}'.format(citation_id))
    curr_citation = Citation.fromdict(data)
    report = curr_citation.remove_project(project_id)
    if isinstance(report, str):
        ref.eprint('could not remove project ({})'.format(report))
        return
    ref.db.child("citations/{}".format(citation_id)).set(
        curr_citation.data, ref.token)
    ref.eprint('citation #{} updated'.format(citation_id))
    # update change
    update = "citation {} removed from project {}".format(
        citation_id, project_id)
    ti = datetime.datetime.now()
    t = str(ti.day) + '-' + str(ti.month) + '-' + str(ti.year) + ' ' + str(
        ti.hour) + ':' + str(ti.minute)
    change_update(ref, t, update)
Example #2
0
def citation_remove_contributor(ref, citation_id, type):
    """remove first appearance of contributor of the same type in citation by its id
    :param ref:Firebase
    :param citation_id:str
    :param type:str
    """
    citation_id = str(citation_id)
    if not ref.exists('citations', citation_id):
        ref.eprint("citation #{} does'nt exist".format(citation_id))
        return
    data = ref.get('citations/{}'.format(citation_id))
    curr_citation = Citation.fromdict(data)
    report = curr_citation.remove_contributor(type)
    if isinstance(report, str):
        ref.eprint('could not remove contributor ({})'.format(report))
        return
    ref.db.child("citations/{}".format(citation_id)).set(
        curr_citation.data, ref.token)
    ref.eprint('removed contributor from citation #{}'.format(citation_id))
    # update change
    update = "citation {} updated".format(citation_id)
    ti = datetime.datetime.now()
    t = str(ti.day) + '-' + str(ti.month) + '-' + str(ti.year) + ' ' + str(
        ti.hour) + ':' + str(ti.minute)
    change_update(ref, t, update)
Example #3
0
def citation_set_type(ref, citation_id, type):
    """change citation type in database by its id
    :param ref:Firebase
    :param citation_id:str
    :param type:str
    """
    citation_id = str(citation_id)
    if not ref.exists('citations', citation_id):
        ref.eprint("citation #{} does'nt exist".format(citation_id))
        return
    data = ref.get('citations/{}'.format(citation_id))
    curr_citation = Citation.fromdict(data)
    report = curr_citation.set_type(type)
    if isinstance(report, str):
        ref.eprint('could not set publication type ({})'.format(report))
        return
    ref.db.child("citations/{}".format(citation_id)).set(
        curr_citation.data, ref.token)
    ref.eprint('changed citation #{} type to {}'.format(citation_id, type))
    # update change
    update = "citation {} updated".format(citation_id)
    ti = datetime.datetime.now()
    t = str(ti.day) + '-' + str(ti.month) + '-' + str(ti.year) + ' ' + str(
        ti.hour) + ':' + str(ti.minute)
    change_update(ref, t, update)
Example #4
0
def citation_change_project_status(ref, citation_id, project_id,
                                   project_status):
    """change status of project in citation
    :param ref:Firebase
    :param citation_id:str
    :param project_id:str
    :param project_status:str
    """
    citation_id = str(citation_id)
    project_id = str(project_id)
    if not ref.exists('citations', citation_id):
        ref.eprint("citation #{} does'nt exist".format(citation_id))
        return
    if not ref.exists('projects', project_id):
        ref.eprint("project #{} does'nt exist".format(project_id))
        return
    data = ref.get('citations/{}'.format(citation_id))
    curr_citation = Citation.fromdict(data)
    report = curr_citation.change_project_status(project_id, project_status)
    if isinstance(report, str):
        ref.eprint('could not change project status ({})'.format(report))
        return
    ref.db.child("citations/{}".format(citation_id)).set(
        curr_citation.data, ref.token)
    ref.eprint('citation #{} updated'.format(citation_id))
Example #5
0
def citation_add_contributor(ref, citation_id, type, name):
    """add contributor to citation by its id
    :param ref:Firebase
    :param citation_id:str
    :param type:str
    :param name:str
    """
    if not name_check(ref, name):
        print("contributer not available")
        return
    citation_id = str(citation_id)
    if not ref.exists('citations', citation_id):
        ref.eprint("citation #{} does'nt exist".format(citation_id))
        return
    data = ref.get('citations/{}'.format(citation_id))
    curr_citation = Citation.fromdict(data)
    report = curr_citation.add_contributor(type, name)
    if isinstance(report, str):
        ref.eprint('could not add contributor ({})'.format(report))
        return
    ref.db.child("citations/{}".format(citation_id)).set(
        curr_citation.data, ref.token)
    ref.eprint('add contributor to citation #{}'.format(citation_id))
    # update change
    update = "citation {} updated".format(citation_id)
    ti = datetime.datetime.now()
    t = str(ti.day) + '-' + str(ti.month) + '-' + str(ti.year) + ' ' + str(
        ti.hour) + ':' + str(ti.minute)
    change_update(ref, t, update)
Example #6
0
def citation_add_project(ref, citation_id, project_id):
    """add project to citation
    :param ref:Firebase
    :param citation_id:str
    :param project_id:str
    """
    citation_id = str(citation_id)
    project_id = str(project_id)
    if not ref.exists('citations', citation_id):
        ref.eprint("citation #{} does'nt exist".format(citation_id))
        return
    if not ref.exists('projects', project_id):
        ref.eprint("project #{} does'nt exist".format(project_id))
        return
    if ref.exists('citations/{}/projects'.format(citation_id), project_id):
        ref.eprint("project #{} allready in citation #{}".format(
            project_id, citation_id))
        return
    data = ref.get('citations/{}'.format(citation_id))
    curr_citation = Citation.fromdict(data)
    report = curr_citation.add_project(project_id)
    if isinstance(report, str):
        ref.eprint('could not add project ({})'.format(report))
        return
    ref.db.child("citations/{}".format(citation_id)).set(
        curr_citation.data, ref.token)
    ref.eprint('citation #{} updated'.format(citation_id))
Example #7
0
def citation_fill_data(ref, citation_id):
    """fill citation data in database by its id
    :param ref:Firebase
    :param citation_id:str
    """
    citation_id = str(citation_id)
    if not ref.exists('citations', citation_id):
        ref.eprint("citation #{} does'nt exist".format(citation_id))
        return
    data = ref.get('citations/{}'.format(citation_id))
    curr_citation = Citation.fromdict(data)
    report = curr_citation.fill_data()
    if isinstance(report, str):
        ref.eprint('could not fill citation data ({})'.format(report))
        return
    ref.db.child("citations/{}".format(citation_id)).set(
        curr_citation.data, ref.token)
    ref.eprint('citation #{} updated'.format(citation_id))
Example #8
0
def citation_set_type(ref, citation_id, type):
    """change citation type in database by its id
    :param ref:Firebase
    :param citation_id:str
    :param type:str
    """
    citation_id = str(citation_id)
    if not ref.exists('citations', citation_id):
        ref.eprint("citation #{} does'nt exist".format(citation_id))
        return
    data = ref.get('citations/{}'.format(citation_id))
    curr_citation = Citation.fromdict(data)
    report = curr_citation.set_type(type)
    if isinstance(report, str):
        ref.eprint('could not set publication type ({})'.format(report))
        return
    ref.db.child("citations/{}".format(citation_id)).set(
        curr_citation.data, ref.token)
    ref.eprint('changed citation #{} type to {}'.format(citation_id, type))
Example #9
0
def citation_remove_contributor(ref, citation_id, type):
    """remove first appearance of contributor of the same type in citation by its id
    :param ref:Firebase
    :param citation_id:str
    :param type:str
    """
    citation_id = str(citation_id)
    if not ref.exists('citations', citation_id):
        ref.eprint("citation #{} does'nt exist".format(citation_id))
        return
    data = ref.get('citations/{}'.format(citation_id))
    curr_citation = Citation.fromdict(data)
    report = curr_citation.remove_contributor(type)
    if isinstance(report, str):
        ref.eprint('could not remove contributor ({})'.format(report))
        return
    ref.db.child("citations/{}".format(citation_id)).set(
        curr_citation.data, ref.token)
    ref.eprint('removed contributor from citation #{}'.format(citation_id))
Example #10
0
def citation_add_contributor(ref, citation_id, type, name):
    """add contributor to citation by its id
    :param ref:Firebase
    :param citation_id:str
    :param type:str
    :param name:str
    """
    citation_id = str(citation_id)
    if not ref.exists('citations', citation_id):
        ref.eprint("citation #{} does'nt exist".format(citation_id))
        return
    data = ref.get('citations/{}'.format(citation_id))
    curr_citation = Citation.fromdict(data)
    report = curr_citation.add_contributor(type, name)
    if isinstance(report, str):
        ref.eprint('could not add contributor ({})'.format(report))
        return
    ref.db.child("citations/{}".format(citation_id)).set(
        curr_citation.data, ref.token)
    ref.eprint('add contributor to citation #{}'.format(citation_id))