コード例 #1
0
def getScreen(stdscr, donations):
    rows = len(donations) + 3
    donations = [[
        DonationButton(i + 2, 1, donations[i]['name'], donations[i])
    ] for i in range(len(donations))]
    donations += [[BackButton(rows - 1, 1, "Back")]]

    sess = utils.getSession()
    return Screen(stdscr, rows, 4, [], donations)
コード例 #2
0
 def press(self, stdscr, inps):
     stdscr.clear()
     category = inps[0][0].inputted
     name = inps[1][0].inputted
     sess = utils.getSession()
     r = requests.get(API_URL + '/' + sess['role'] + '/searchdonations',
                      params={
                          'category': category,
                          'name': name
                      },
                      headers={'Authorization': 'Bearer ' + sess['jwt']})
     js = r.json()
     return searchresults.getScreen(stdscr, js['donations'])
コード例 #3
0
def getScreen(stdscr):
    sess = utils.getSession()
    inps = [
        SearchButton(2, 1, "Search"),
        AddButton(2, 2, "Add"),
        BackButton(2, 3, "Back")
    ] if sess['role'] == 'employees' or sess['role'] == 'managers' else [
        SearchButton(2, 1, "Search"),
        BackButton(2, 3, "Back")
    ]
    return Screen(
        stdscr, 3, 4,
        [Text(1, 2, 'Would you like to add or search for donations?')], [inps])
コード例 #4
0
def getScreen(stdscr):
    r = requests.get(API_URL + '/locations')
    js = r.json()
    rows = len(js['locations']) + 4
    locations = [[LocationButton(i + 2, 2, js['locations'][i]['name'], js['locations'][i])] for i in range(len(js['locations']))]
    locations += [[DonationsButton(rows - 1, 1, "Donations"), MapButton(rows - 1, 2, "Map"), BackButton(rows - 1, 3, "Back")]]

    sess = utils.getSession()
    return Screen(
        stdscr,
        rows,
        4,
        [
            Text(1, 2, 'Welcome %s %s you are a %s.' % (sess['firstname'], sess['lastname'], sess['role'][:len(sess['role']) - 1]))
        ],
        locations
    )
コード例 #5
0
def index():
    """Main landing page"""
    timezone = getSession(request, "timezone", "US/Eastern")
    start_date = datetime.now() + timedelta(30)
    year = datetime.now().year
    years = range(year, year+12)
    months = list(calendar.month_name)[1:]
    cal = calendar.Calendar()

    # Set weekday to start on sunday to match grid
    cal.setfirstweekday(6)

    # Get day num and weekday num tuple
    days = cal.itermonthdays2(start_date.year, start_date.month)
    return render(request, 'index', {'years': years, 'months': months,
                                     'days': days, 'cur_year': year, 'cur_month': start_date.month,
                                     'cur_day': start_date.day, 'timezone': timezone})
コード例 #6
0
 def press(self, stdscr, inps):
     stdscr.clear()
     name = inps[0][0].inputted
     shortDesc = inps[1][0].inputted
     desc = inps[2][0].inputted
     value = inps[3][0].inputted
     category = inps[4][0].inputted
     sess = utils.getSession()
     r = requests.post(API_URL + '/' + sess['role'] + '/adddonation',
                       data={
                           'name': name,
                           'shortdescription': shortDesc,
                           'description': desc,
                           'value': value,
                           'category': category
                       },
                       headers={'Authorization': 'Bearer ' + sess['jwt']})
     js = r.json()
     if js['error'] != 0:
         return getScreen(stdscr)
     else:
         return donations.getScreen(stdscr)
コード例 #7
0
ファイル: aperturaBuste.py プロジェクト: Dartenor/FantaBot
        calciatoreId = int(movimento['calciatori_m'])
        for calciatore in calciatori:
            if calciatore['id'] == calciatoreId:
                movimento['player'] = calciatore
        teamId = int(movimento['id_squadra_m'])
        for team in teams['data']:
            if team['id'] == teamId:
                movimento['team'] = team

    message = 'Aperte le buste per la tornata odierna:'

    if len(movimentiBuste) == 0:
        message = message + '\n--Nessuna busta presente--'
    else:
        for movimento in movimentiBuste:
            message = message + '\n' + movimento['player'][
                'r'] + ' ' + movimento['player']['n'] + ' (' + movimento[
                    'player']['s'] + ') a ' + movimento['team'][
                        'nome'] + ' per ' + str(movimento['costo_m'])

    message = message + '\n\n(Le eventuali buste terminate in parità non sono presenti in questa lista)'
    utils.sendMessage(session, message)
    return True


session = utils.getSession()
result = apriBuste(session, firstTime=True)
if not result:
    utils.login(session)
    apriBuste(session, firstTime=False)
コード例 #8
0
def mdy(month, day, year):
    """Day calculation view"""
    timezone = getSession(request, "timezone", "US/Eastern")
    now = datetime.now()
    result = timeuntil(now, datetime(year, month, day), timezone)
    return render(request, 'mdy', {'result': result, 'timezone': timezone})