Ejemplo n.º 1
0
def get_attedance(cca, date):
    # Insert the logic here
    try:
        worksheet = get_worksheet(cca)
        members_data = worksheet.get_all_values()[1:]

        print(members_data)

        total_attendance = [0]
        member_attendance = []
        print("Date: " + date)

        cell = worksheet.find(date)

        col = cell.col  #Date column

        print(col)

        for member in members_data:
            name = member[2]
            attendance = member[col - 1]
            print(name + attendance)
            if member[col - 1] == '':
                member_attendance.append((name, 'No Response'))
            else:
                member_attendance.append((name, attendance))
                total_attendance[0] += int(attendance)

        return [member_attendance, total_attendance]
    except:
        print("No date found")
        return []
Ejemplo n.º 2
0
def get_ccas_by_category(category):
    worksheet = get_worksheet("CCA")

    cell = worksheet.find(category)
    col_number = cell.col
    ccas = worksheet.col_values(col_number)
    return ccas[1:]
Ejemplo n.º 3
0
def get_attendance_date_list(cca):
    worksheet = get_worksheet(cca)
    data = worksheet.row_values(1)
    if len(data) == 5:
        return []

    return data[5:]
Ejemplo n.º 4
0
def get_all_cca_members_id(cca):
    try:
        worksheet = get_worksheet(cca)
        username = worksheet.col_values(1)

        return username[1:]

    except:

        print("Worksheet Not Found")
Ejemplo n.º 5
0
def get_user_position(name, cca):
    worksheet = get_worksheet(cca)

    try:
        if is_registered(name):
            cell = worksheet.find(name)
            row_number = cell.row
            user = worksheet.row_values(row_number)
            position = user[4]
            return position
        else:
            raise ValueError('User not registered')
    except ValueError:
        return -1
Ejemplo n.º 6
0
def mark_attendance(name, data):
    # Add logic here
    status = data[1]  # CAN/CANNOT
    cca = data[2]
    date = data[3]
    worksheet = get_worksheet(cca)
    cell1 = worksheet.find(name)
    cell2 = worksheet.find(date)

    row = cell1.row
    col = cell2.col

    if status == "CAN":
        worksheet.update_cell(row, col, 1)
        return True
    else:
        worksheet.update_cell(row, col, 0)
        return True
    return False
Ejemplo n.º 7
0
def get_attendance(name, cca_name):
    # Add logic here
    attendance_count = [0]
    dates = []
    sh = [dates, attendance_count]
    worksheet = get_worksheet(cca_name)
    cell = worksheet.find(name)
    row = cell.row
    col = 6
    val = 0
    while (worksheet.cell(1, col).value != None):
        val = worksheet.cell(row, col).value

        if (val == '1'):
            attendance_count[0] = attendance_count[0] + 1

        dates.append((worksheet.cell(1, col).value, worksheet.cell(row,
                                                                   col).value))
        col = col + 1

    logger.info(sh)
    return sh
Ejemplo n.º 8
0
def add_user_to_worksheet(user_data, cca_list):
    user_data = user_data + ['Member']
    for cca in cca_list:
        worksheet = get_worksheet(cca)
        worksheet.append_row(user_data)
    return True
Ejemplo n.º 9
0
from spreadsheet.service import get_worksheet

worksheet = get_worksheet("Master")
'''
Add utility/helper function to edit the spreadsheet
'''


def get_user_ccas(name):
    # Insert the logic here
    try:
        if is_registered(name):
            cell = worksheet.find(name)
            row_number = cell.row
            user = worksheet.row_values(row_number)
            ccas = user[4:]
            return ccas
        else:
            raise ValueError('User not registered')
    except ValueError:
        print("User not registered")


def get_user_position(name, cca):
    worksheet = get_worksheet(cca)

    try:
        if is_registered(name):
            cell = worksheet.find(name)
            row_number = cell.row
            user = worksheet.row_values(row_number)
Ejemplo n.º 10
0
from spreadsheet.service import get_worksheet
import logging

worksheet = get_worksheet("CCA")

logging.basicConfig(
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    level=logging.INFO)
logger = logging.getLogger(__name__)
'''
Add head relevant function to edit the spreadsheet
'''


def get_attendance(name, cca_name):
    # Add logic here
    attendance_count = [0]
    dates = []
    sh = [dates, attendance_count]
    worksheet = get_worksheet(cca_name)
    cell = worksheet.find(name)
    row = cell.row
    col = 6
    val = 0
    while (worksheet.cell(1, col).value != None):
        val = worksheet.cell(row, col).value

        if (val == '1'):
            attendance_count[0] = attendance_count[0] + 1

        dates.append((worksheet.cell(1, col).value, worksheet.cell(row,
Ejemplo n.º 11
0
def add_date(cca, date):
    worksheet = get_worksheet(cca)
    values_list = worksheet.row_values(1)
    col = len(values_list) + 1

    cell = worksheet.update_cell(1, col, date)