diff --git a/app/routes.py b/app/routes.py index 7f2125b..7503210 100644 --- a/app/routes.py +++ b/app/routes.py @@ -3,32 +3,53 @@ from datetime import date from flask import render_template from app import app -def get_ride_data( basename ): +class Raffle_Winner(): + def __init__(self, the_number,the_teacher,the_grade): + self.number = the_number + self.teacher = the_teacher + self.grade = the_grade + +class Participants(): + total = tk = k = g1 = g2 = g3 = g4 = g5 = 0 +class Ride(): + date = None + treats = [] + participants = Participants() + classroom = None + raffle_winners = [] + +def get_ride_data( a_date ): ##TODO: process just first line if file just has one line (treats) + r = Ride() + try: - next_ride_file = open( getcwd() + sep + "data/"+date.strftime(basename,"%Y-%m-%d")+".txt") + next_ride_file = open( getcwd() + sep + "data/rides/"+date.strftime(a_date,"%Y-%m-%d")+".txt") lines = [ line for line in next_ride_file.read().split("\n") ] - next_ride_object = { - "treats": lines[0].split(","), - lines[1].split(",")[0]:lines[1].split(",")[1], - lines[2].split(",")[0]:lines[2].split(",")[1], - lines[3].split(",")[0]:lines[3].split(",")[1], - lines[4].split(",")[0]:lines[4].split(",")[1], - lines[5].split(",")[0]:lines[5].split(",")[1], - lines[6].split(",")[0]:lines[6].split(",")[1], - lines[7].split(",")[0]:lines[7].split(",")[1], - lines[8].split(",")[0]:lines[8].split(",")[1], - "winner1":list(lines[9].split(",")), - "winner2":list(lines[10].split(",")), - "winner3":list(lines[11].split(",")), - } + if len(lines) > 1: + r.treats = list( lines[0].split(",") ) + r.participants.total = lines[1].split(",")[1] + r.participants.tk = lines[2].split(",")[1] + r.participants.k = lines[3].split(",")[1] + r.participants.g1 = lines[4].split(",")[1] + r.participants.g2 = lines[5].split(",")[1] + r.participants.g3 = lines[6].split(",")[1] + r.participants.g4 = lines[7].split(",")[1] + r.participants.g5 = lines[8].split(",")[1] + r.classroom = list( lines[9].split(",")[1:3] ) + r.raffle_winners = [] + tmp_list = list(lines[10].split(",")) + for w in tmp_list: + winner_data = list(w.split("-")) + r.raffle_winners.append( Raffle_Winner(winner_data[0],winner_data[1],winner_data[2])) + elif len(lines) == 1: + r.treats = list( lines[0].split(",") ) except: - next_ride_object = None + pass - file = next_ride_object - return file -def get_rides(): + ##file = next_ride_object + return r +def get_rides_dates(): rides_file = open( getcwd() + sep + "data/rides.txt") rides = [ date.strptime( ride_date_str ,"%Y/%m/%d") for ride_date_str in rides_file.read().split("\n") ] return rides @@ -40,21 +61,40 @@ def get_next_ride_date( rides_list ): active_rides.append( ride_date ) next_ride = active_rides[0] return next_ride -def get_week_day_name( a_date ): - return date.strftime( a_date ,"%A, %B %d" ) -def get_short_day_name_and_date( a_date ): - return date.strftime( a_date ,"%b %d" ) +def get_rides_data( dates ): + n = 0 + rides_files = [] + rides_data = [] + for d in dates: + data = Ride() + data.date = d + data.treats = [] + data.participants.total = 0 + data.participants.tk = 0 + data.participants.k = 0 + data.participants.g1 = 0 + data.participants.g2 = 0 + data.participants.g3 = 0 + data.participants.g4 = 0 + data.participants.g5 = 0 + + data.classroom = None + data.raffle_winners = [] + + rides_data.append( data ) + + return rides_data @app.route('/') @app.route('/index') @app.route('/home') def index(): - rides = get_rides() + rides = get_rides_dates() next_ride = get_next_ride_date(rides) user = {'username': 'Jorge'} - month_and_day = get_week_day_name( next_ride ) - short_day_name_and_date = get_short_day_name_and_date( next_ride ) + month_and_day = date.strftime( next_ride ,"%A, %B %d" ) + short_day_name_and_date = date.strftime( next_ride ,"%b %d" ) next_ride_data = get_ride_data( next_ride ) posts = [ { @@ -72,8 +112,9 @@ def index(): @app.route('/ride') @app.route('/walk') def ride(): - rides = get_rides() - next_ride = get_next_ride_date(rides) + rides_dates = get_rides_dates() + next_ride = get_next_ride_date( rides_dates ) next_ride_data = get_ride_data( next_ride ) - - return render_template( 'ride.html', rides=rides, next_ride_data=next_ride_data, title='Home', next_ride=next_ride) ## objects/variables to send over to templates. + rides_data = get_rides_data( rides_dates ) + x = get_ride_data( next_ride ) + return render_template( 'ride.html', x=x, rides_data=rides_data, rides_dates=rides_dates, next_ride_data=next_ride_data, title='Home', next_ride=next_ride) ## objects/variables to send over to templates. diff --git a/app/static/style.css b/app/static/style.css index e431e4c..a9ae86f 100644 --- a/app/static/style.css +++ b/app/static/style.css @@ -23,12 +23,31 @@ --wr-yellow:#e8d55d; --wr-yellow-filter:filter: invert(77%) sepia(30%) saturate(679%) hue-rotate(12deg) brightness(101%) contrast(98%); --wr-black:#0c1625; - --wr-border-radius: 1.25em; - --wr-widget-height: 1.5em; - --wr-active-widget-height: 2em; --heart: url("data:image/svg+xml;utf8,"); --arrow_before: url(/static/img/arrow_before.svg); --arrow_after: url(/static/img/arrow_after.svg); + --min_width_mobile: 500px; + --wr-h-letter-spacing: -.075em; + --wr-border-radius: 1.25em; + --wr-widget-height: 1.5em; + --wr-active-widget-height: 2em; + @media screen and ( width > 500px ) { + --wr-html-font-size: 1.25em; + --wr-background-size: 12em; + --wr-h1-font-size:2.25em; + --wr-h3-font-size:1.5em; + --wr-emwrlogo-max-height:13em; + --wr-widget-scale: 1; + } + @media screen and ( width <= 500px ) { + --wr-html-font-size: var(.125em); + --wr-background-size: 10em; + --wr-h1-font-size:1.75em; + --wr-h3-font-size:1em; + --wr-emwrlogo-max-height:8em; + --wr-widget-scale: .75; + } + } /*Fonts*/ @font-face { @@ -50,59 +69,56 @@ html,body{ padding: 0px; line-height: .95; scroll-behavior:smooth; - transition: all 1s ease-out; + /* transition: all 1s ease-out; */ } - html{ font-family: abelRegular; - font-size: 1.25em; + font-size: var(--wr-html-font-size); } body{ background-color: var(--violet-main-color); background-image: url("./img/pattern.svg"); background-attachment: fixed; - background-size: 12em; + background-size: var(--wr-background-size); max-width: 100%; display: flex; flex-direction: column; } - h1,h3{ - letter-spacing: -.075em; + letter-spacing: var(--wr-h-letter-spacing); color: var(--wr-yellow); padding-top: 0px; margin-top: 0px; margin-bottom: 0px; } - h1{ - font-size: 2.25em; + font-size: var(--wr-h1-font-size); } h3{ - font-size: 1.5em; + font-size: var(--wr-h3-font-size); } - img{ max-width: 100%; } + /*Useful Layout Classes*/ + + div.page{ display: flex; justify-content: center; align-items: center; max-width: 100%; } - div.container{ display: flex; flex-direction: column; max-width: 40em; align-items:center; } - .section{ height: 100vh; /* background-color: #d5231133; @@ -110,37 +126,57 @@ div.container{ border-width: 1px; */ /*scale: .75;*/ } - .row{ display: flex; flex-direction: row; } - .column{ display: flex; flex-direction: column; } - .wrapping{ flex-wrap: wrap; } - .centered{ display: flex; justify-content: center; align-items: center; } - -.box{ - padding-top: 1em; - padding-bottom: 1em; - padding-left: 1.5em; - padding-right: 1.5em; - margin-left:2em; - margin-right:2em; - margin-top: 0px; - margin-bottom: 0px; +@media screen and ( width <= 500px ) { + .box{ + padding-top: .5em; + padding-bottom: .5em; + padding-left: .75em; + padding-right: .75em; + margin-left: 1em; + margin-right:1em; + margin-top: 0px; + margin-bottom: 0px; + } + } +@media screen and ( width >= 500px) { + .box{ + padding-top: 1em; + padding-bottom: 1em; + padding-left: 1.5em; + padding-right: 1.5em; + margin-left:2em; + margin-right:2em; + margin-top: 0px; + margin-bottom: 0px; + } +} +.box.left{ + margin-right: 0px; +} +.box.right{ + margin-left: 0px; +} +.big{ + font-size: +3em; + letter-spacing: -.1em; + } /* .box:hover{ padding-top: 5em; } */ @@ -154,11 +190,11 @@ div.container{ } .menu{ + scale: var(--wr-widget-scale); position: absolute; top: 0em; justify-content: center; } - .section{ padding: 0px; margin: 0px; @@ -204,68 +240,59 @@ div.container{ } /*Images*/ - a.menuitem{ padding-left: 1em; padding-right: 1em; } -img.icon{ +img.icon,object.icon{ display: block; max-width: 100%; max-height: 3em; border-radius: 0em; padding: .5em; } - img.emwrlogo{ - max-height: 13em; + + max-height: var(--wr-emwrlogo-max-height); background-size: cover; background-image: url('/static/img/backpack_purple.webp'); position: relative; margin-bottom:1em; } - object.map{ max-width: 100%; border-radius: var(--wr-border-radius); } - img.photo{ padding: .25em; height: 12em; object-fit: cover; border-radius: var(--wr-border-radius); } - img.photo.main{ width: 100%; height: auto; } - img.photo.A{ width: 12em; } - img.photo.B{ width: 18em; } - img.photo.C{ width: 8em; } /*Colors*/ - .yellow{ color: var(--wr-yellow); } +/* Classes */ .ccwr_url{ background-color: #390747; } - /*?*/ - .ride_date{ display: block; padding: .5em; @@ -273,15 +300,12 @@ img.photo.C{ letter-spacing: -.075em; color: var(--wr-white); } - .next_ride_date{ color:var(--wr-yellow); } - .ride_date.active{ color: var(--wr-dark-blue); } - div.tag_reminder{ position: fixed; overflow-y: scroll; @@ -289,7 +313,9 @@ div.tag_reminder{ top: 1em; right: 1em; } - +.hide{ + display: none; +} .widget{ color:var(--wr-white); height: var(--wr-widget-height); @@ -303,7 +329,6 @@ div.tag_reminder{ .widget:hover{ cursor: pointer; } - .widget-text{ display: flex; height: var(--wr-widget-height); @@ -321,19 +346,19 @@ div.tag_reminder{ color: var(--wr-yellow); font-size: 1em; } - .backpack{ max-height: 15em; width: auto; } - p{ padding-top: 0px; margin-top: .5em; margin-bottom: 0px; } +/* IDs */ #dates_bar{ + scale: var(--wr-widget-scale); bottom: 0px; justify-content: center; overflow-y: scroll; diff --git a/app/templates/base.html b/app/templates/base.html index 0f8e7fb..2d54014 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -11,7 +11,7 @@ {% endif %}
-