Пример #1
0
def newEvent():
    if request.method == 'POST':
        if request.form['name']:
            year = int(request.form['year'])
            month = int(request.form['month'])
            date = int(request.form['date'])
            dateStart = Date.query.filter_by(year=year, month=month,
                                             date=date).one()
            newDates = []
            event = Event(name=request.form['name'],
                          description=request.form['description'],
                          country=request.form['country'],
                          city=request.form['city'],
                          locality=request.form['locality'],
                          url=request.form['url'],
                          youtube=request.form['youtube'])
            if dateStart:
                if request.form.get(
                        'multiple-days'
                ):  #if multiple days checkbox is ticked, add multiple dates
                    yearEnd = int(request.form['year-end'])
                    monthEnd = int(request.form['month-end'])
                    dateEnd = int(request.form['date-end'])
                    dateIsAfter = checkDates(year, month, date, yearEnd,
                                             monthEnd, dateEnd)
                    if dateIsAfter:
                        allSame = False
                        while not allSame:
                            newDate = Date.query.filter_by(year=year,
                                                           month=month,
                                                           date=date).one()
                            newDates.append(newDate)
                            if (year == yearEnd and month == monthEnd
                                    and date == dateEnd):
                                allSame = True
                            else:
                                year, month, date = getNextDate(
                                    year, month, date)
                        event.dates = newDates
                    else:
                        print "You need to make sure the 2nd date is after the first"
                else:  #just change 1 date
                    print "multiple days not ticked"
                    newDates.append(dateStart)
                    event.dates = newDates
            else:
                print "date not found, try a proper date. date not changed"
                return
            db.session.add(event)
            db.session.commit()
            return redirect(url_for('events'))
        else:
            print "Event must have a name"
            return
    else:
        return render_template('newevent.html')
def vol_add_image():
    form = LoginForm()
    if request.method == 'POST':
        date = request.form['date']
        folder = "my_folder/" + str(date) + "/"
        a = "static//images//%s//" % (str(date))
        target = os.path.join(APP_ROUTE, a)
        if not os.path.isdir(target):
            os.mkdir(target)
        f_name = a + "url.txt"
        file = open(f_name, "a+")
        name = request.form['name']
        venue = request.form['venue']
        info = request.form['info']
        hda = list(map(int, str(date).split("-")))
        date = datetime.date(hda[0], hda[1], hda[2])
        # for i in range(int(request.form["count"])):
        for i in range(8):
            pic = request.files.get(str(i))
            if pic:
                url = upload(pic, folder=folder, public_id=str(i))['url']
                url += '\n'
                file.write(url)
        file.close()
        data = Event(name=name,
                     venue=venue,
                     imgloc=f_name,
                     date=date,
                     info=info,
                     vol_id=current_user.id)
        session.add(data)
        session.commit()
        return redirect('/events')
    return render_template('vol_addimage.html')
Пример #3
0
def newEvent(organizer_id):
    organizer = session.query(Organizer).filter_by(id=organizer_id).one()

    if request.method == 'POST':
        featured = 0
        if 'featured' in request.form:
            featured = request.form['featured']

        if None or '' in request.form.values():
            flash(
                'Please make sure that you have entered all necessary data for all form fields'
            )
            return render_template('newEvent.html')

        newEvent = Event(
            name=request.form['name'],
            description=request.form['description'],
            event_url=request.form['event_url'],
            event_thumbnail_url=request.form['event_thumbnail_url'],
            ticket_price=request.form['ticket_price'],
            start_date=datetime.strptime(request.form['start_date'],
                                         '%Y-%M-%d'),
            featured=featured,
            organizer_id=organizer_id,
            user_id=organizer.user_id)
        session.add(newEvent)
        session.commit()
        flash('New Event %s Successfully Created' % (newEvent.name))
        return redirect(url_for('showEvent', organizer_id=organizer_id))
    else:
        return render_template('newEvent.html', organizer_id=organizer_id)
Пример #4
0
def createEvent():
    logged_user = getUserInfo(login_session['user_id'])
    if request.method == 'GET':
        return render_template("create_event.html", logged_user=logged_user)
    elif request.method == 'POST':
        event = Event(user_id=logged_user.id,
                      co_user_id='',
                      type=request.form['type'],
                      year=int(request.form['year']),
                      description=request.form['description'])
        session.add(event)
        session.commit()
        return redirect(url_for('myProfile'))
Пример #5
0
def create_event():
    user = dbsession.query(Person).filter_by(id=session['user_id']).first()
    events = dbsession.query(Event).all()  # Get all events

    if request.method == 'GET':
        currentyear = datetime.now().year
        years = [currentyear, currentyear + 1]
        months = range(1, 13)
        days = range(1, 32)
        return render_template('create_event.html',
                               user=user,
                               years=years,
                               months=months,
                               days=days)

    else:  # If user wants to create an event

        event_exists = False
        for event in events:
            if event.title == request.form['title']:  # If event name exists
                event_exists = True
                break

        if not event_exists:  # Check if event exists flag is set
            event_date = datetime(int(request.form['year']),
                                  int(request.form['month']),
                                  int(request.form['day']))
            event = Event(title=request.form['title'],
                          date=event_date,
                          description=request.form['description'],
                          owner_id=user.id,
                          owner=user,
                          location=request.form['location'])

            event_attendance = Attendance(
                person_id=session['user_id'],
                person=dbsession.query(Person).filter_by(
                    id=session['user_id']).first(),
                event_id=event.id,
                event=event,
                chef_flag=True)

            dbsession.add(event)
            dbsession.add(event_attendance)
            dbsession.commit()
            ## ADD ELSE (EVENT EXISTS) TELL USER

        return redirect(url_for('event_page', event_id=event.id))
Пример #6
0
def add_event():
    if (request.method == 'GET'):
        return render_template("add_event.html")
    # read form data
    else:

        new_name = request.form['name']
        new_date = request.form['date']
        new_style = request.form['style']
        new_location = request.form['location']
        newevent = Event(name=new_name,
                         date=new_date,
                         style=new_style,
                         location=new_location,
                         description=request.form['description'])
        session.add(newevent)
        session.commit()
        # redirect user to the page that views all friends
        return redirect(url_for('main_page'))
def newEvent():
    if 'username' not in login_session:
        return redirect('/login')
    if request.method == 'POST':
        newEvent = Event(
            name=request.form['name'],
            date=datetime.datetime.strptime(request.form['date'], '%Y-%m-%d'),
            timeStart=datetime.datetime.time(datetime.datetime.strptime(
                request.form['timeStart'], '%H:%M')),
            timeEnd=datetime.datetime.time(datetime.datetime.strptime(
                request.form['timeEnd'], '%H:%M')),
            numVolunteers=request.form['numVolunteers'],
            description=request.form['description'],
            user_id=login_session['user_id'])
        session.add(newEvent)
        flash('New Event %s Successfully Created' % newEvent.name)
        session.commit()
        return redirect(url_for('showEvents'))
    else:
        return render_template('newEvent.html')
Пример #8
0
def createEvent():
    """Create a new event"""
    try:
        start = datetime.strptime(request.json['start'], '%Y-%m-%d %H:%M')
        end = datetime.strptime(request.json['end'], '%Y-%m-%d %H:%M')
        assert end > start
    except:
        abort(400, "Incorrect data format, should be YYYY-MM-DD H:M")

    try:
        newEvent = Event(
            name=request.json['name'],
            location=request.json['location'],
            start=request.json['start'],
            end=request.json['end']
        )
        session.add(newEvent)
        session.commit()
        return jsonify(newEvent.serialize), 201
    except:
        abort(400)
Пример #9
0
def newEvent():
    # Query all city locations to populate select menu in form
    locations = session.query(City).all()
    # Only logged in users can add data
    if 'username' not in login_session:
        return redirect('/login')
    if request.method == 'POST':
        # Format date value before submitting to database
        dt = request.form['event_date']
        dt_obj = datetime.strptime(dt, '%Y-%m-%d')

        # Create event object based on form data
        newEvent = Event(
            name=request.form['event'],
            description=request.form['description'],
            event_date=dt_obj, event_url=request.form['event_url'],
            image_url=request.form['image_url'],
            city_id=request.form['city_id'], user_id=login_session['user_id'])
        session.add(newEvent)
        session.commit()
        flash('New Event "%s" Successfully Created' % (newEvent.name))
        return redirect(url_for('showEvent', city_id=newEvent.city_id))
    else:
        return render_template('newEvent.html', locations=locations)
Пример #10
0
    name="Mohammed Safwat",
    email="*****@*****.**",
    picture=
    'https://pbs.twimg.com/profile_images/519046593937281024/KLDpy046_400x400.png'
)
session.add(User1)
session.commit()

organizer1 = Organizer(
    user_id=1,
    name="Virgin Megastore",
    organizer_thumbnail_url=
    "http://the3doodler.com/wp-content/uploads/2015/02/virgin_megastore.jpg")

session.add(organizer1)
session.commit()

event1 = Event(user_id=1,
               name="RedFest DXB",
               event_url="http://tickets.virginmegastore.me/?event_id=3494",
               event_thumbnail_url="",
               description="VirignMegastore RedFest",
               ticket_price="$7.50",
               start_date=datetime.now(),
               featured=True)

session.add(event1)
session.commit()

print "added events!"
Пример #11
0
def createPublicHolidays2018():
    newYearsDayDate = Date.query.filter_by(year=2018, month=1, date=1).one()
    newYearsDay = Event(name="New Year's Day",
                        description='The day after the new year.',
                        country='',
                        city='',
                        locality='',
                        url='',
                        youtube='')
    newYearsDayDate.events.append(newYearsDay)

    goodFriDate = Date.query.filter_by(year=2018, month=3, date=30).one()
    goodFri = Event(name="Good Friday",
                    description='Friday for Easter',
                    country='',
                    city='',
                    locality='',
                    url='',
                    youtube='')
    goodFriDate.events.append(goodFri)

    easterMonDate = Date.query.filter_by(year=2018, month=4, date=2).one()
    easterMon = Event(name='Easter Monday',
                      description='The Monday during Easter',
                      country='',
                      city='',
                      locality='',
                      url='',
                      youtube='')
    easterMonDate.events.append(easterMon)

    earlyMayBankDate = Date.query.filter_by(year=2018, month=5, date=7).one()
    earlyMayBank = Event(name='Early May Bank Holiday',
                         description='Bank holiday for early May',
                         country='England',
                         city='',
                         locality='',
                         url='',
                         youtube='')
    earlyMayBankDate.events.append(earlyMayBank)

    springBankDate = Date.query.filter_by(year=2018, month=5, date=28).one()
    springBank = Event(name='Spring Bank Holiday',
                       description='Bank holiday for Spring',
                       country='England',
                       city='',
                       locality='',
                       url='',
                       youtube='')
    springBankDate.events.append(springBank)

    summerHolDate = Date.query.filter_by(year=2018, month=8, date=27).one()
    summerHol = Event(name='Summer Bank Holiday',
                      description='A public holiday in Summer for banks',
                      country='England',
                      city='',
                      locality='',
                      url='',
                      youtube='')
    summerHolDate.events.append(summerHol)

    xmasDayDate = Date.query.filter_by(year=2018, month=12, date=25).one()
    xmasDay = Event(name='Christmas Day',
                    description='Christmas is here!',
                    country='',
                    city='',
                    locality='',
                    url='',
                    youtube='')
    xmasDayDate.events.append(xmasDay)

    boxingDayDate = Date.query.filter_by(year=2018, month=12, date=26).one()
    boxingDay = Event(name='Boxing Day',
                      description='The day after Christmas',
                      country='',
                      city='',
                      locality='',
                      url='',
                      youtube='')
    boxingDayDate.events.append(boxingDay)

    db.session.commit()
    print "Added 2018 London public holidays."
Пример #12
0
def addSportEvents2018():
    ausOpen = Event(
        name='Australian Open',
        description=
        'The first of four tennis grand slam tournaments each year held in Australia.',
        country='Australia',
        city='Melbourne',
        locality='Melbourne Park',
        url='https://ausopen.com/',
        youtube='MjO1HdcbMuc')
    for x in range(15, 29):
        date = Date.query.filter_by(year=2018, month=1, date=(x)).one()
        ausOpen.dates.append(date)

    commonwealthGames = Event(
        name='Commonwealth Games',
        description=
        'Sporting event between elite athletes of countries from the Commonwealth.',
        country='Australia',
        city='Gold Coast',
        locality='',
        url='https://www.gc2018.com/',
        youtube='d38pGyRuXhw')
    for x in range(4, 16):
        date = Date.query.filter_by(year=2018, month=4, date=(x)).one()
        commonwealthGames.dates.append(date)

    faCupFinal = Event(
        name='FA Cup Final',
        description='The final match of the Football Association Challenge Cup',
        country='England',
        city='London',
        locality='',
        url='www.thefa.com/competitions/thefacup',
        youtube='Vcr_SiJ5OJU')
    date = Date.query.filter_by(year=2018, month=5, date=19).one()
    faCupFinal.dates.append(date)

    uefaChampsFinal = Event(
        name='UEFA Champions League Final',
        description='The final game in the UEFA Champions League',
        country='Ukraine',
        city='Kiev',
        locality='NSC Olimpiyskiy Stadium',
        url='https://www.uefa.com/uefachampionsleague/',
        youtube='GKAg22tPyqM')
    date = Date.query.filter_by(year=2018, month=5, date=26).one()
    uefaChampsFinal.dates.append(date)

    frenchOpen = Event(
        name='Roland-Garros',
        description=
        'Also known as The French Open, this tennis grand slam is held on courts with clay surfaces.',
        country='France',
        city='Paris',
        locality='Stade Roland Garros',
        url='www.rolandgarros.com/',
        youtube='QNgE9-0sNjQ')
    for x in range(27, 32):
        date = Date.query.filter_by(year=2018, month=5, date=(x)).one()
        frenchOpen.dates.append(date)
    for x in range(1, 11):
        date = Date.query.filter_by(year=2018, month=6, date=(x)).one()
        frenchOpen.dates.append(date)

    fifaWorldCup = Event(
        name='FIFA World Cup',
        description=
        "The World's most watched global sporting event held every four years.",
        country='Russia',
        city='',
        locality='',
        url='http://www.fifa.com/',
        youtube='fTYgpGdvFa4')
    for x in range(14, 31):
        date = Date.query.filter_by(year=2018, month=6, date=(x)).one()
        fifaWorldCup.dates.append(date)
    for x in range(1, 16):
        date = Date.query.filter_by(year=2018, month=7, date=(x)).one()
        fifaWorldCup.dates.append(date)

    nbaFinalsStart = Event(
        name='NBA Finals (start)',
        description=
        'The start of the American National Basketball League finals series.',
        country='USA',
        city='',
        locality='',
        url='www.nba.com/',
        youtube='_qAw-kqM52E&t=4s')
    date = Date.query.filter_by(year=2018, month=5, date=31).one()
    nbaFinalsStart.dates.append(date)

    tourDeFrance = Event(
        name='Tour De France',
        description=
        'The biggest multistage outdoor cycling competition held in France every year.',
        country='France',
        city='',
        locality='',
        url='www.letour.fr/en/',
        youtube='AGTTklH8E8I')
    for x in range(7, 30):
        date = Date.query.filter_by(year=2018, month=7, date=(x)).one()
        tourDeFrance.dates.append(date)

    wimbledon = Event(
        name='Wimbledon',
        description=
        'The last of four tennis grand slam tournamnets each year held in Wimbledon, England.',
        country='England',
        city='London',
        locality='Wimbledon',
        url='www.wimbledon.com/',
        youtube='1BKicTE-gvQ')
    for x in range(2, 16):
        date = Date.query.filter_by(year=2018, month=7, date=(x)).one()
        wimbledon.dates.append(date)

    melbourneCup = Event(
        name='Melbourne Cup',
        description='A major horse racing event held in Melbourne Australia',
        country='Australia',
        city='Melbourne',
        locality='Flemington Racecourse',
        url='https://www.flemington.com.au/melbournecupcarnival',
        youtube='rjKtYir06m0')
    date = Date.query.filter_by(year=2018, month=11, date=6).one()
    melbourneCup.dates.append(date)

    db.session.commit()
    print "Added 2018 sport events."
Пример #13
0

# Clear database tables - City and Event
session.query(City).delete()
session.query(Event).delete()
session.commit()


# City info for San Francisco
city1 = City(name = "San Francisco", state="California")

session.add(city1)
session.commit()


event1 = Event(name = "Droidcon San Francisco 2015", description = "The droidcon conferences around the world support the Android platform and create a global network for developers and companies. We offer best-in-class presentations from leaders in all parts of the Android ecosystem, including core development, embedded solutions augmented reality, business solutions and games.", city = city1)

session.add(event1)
session.commit()

event2 = Event(name = "SF Android User Group", description = "We are an interactive group of Android developers and contractors discussing trends in technology, business, and job outlook.", city = city1)

session.add(event2)
session.commit()

# menuItem3 = MenuItem(name = "Chocolate Cake", description = "fresh baked and served with ice cream", price = "$3.99", course = "Dessert", restaurant = restaurant1)

# session.add(menuItem3)
# session.commit()

# menuItem4 = MenuItem(name = "Sirloin Burger", description = "Made with grade A beef", price = "$7.99", course = "Entree", restaurant = restaurant1)
Пример #14
0
User1 = User(
    name="Meow Meow",
    email="*****@*****.**",
    picture=('https://www.catster.com/wp-content/uploads/'
             '2018/07/Savannah-cat-lying-down.jpg'),
    id=1)
session.add(User1)
session.commit()


# Create Princeton Arduino Event
event1 = Event(
    name="Princeton HISPA Smart Traffic Light Arduino Workshop",
    date=datetime.date(2019, 6, 7),
    timeStart=datetime.time(11, 30),
    timeEnd=datetime.time(12, 30),
    numVolunteers=6,
    description=("Located off-site at Princeton University,"
                 " requires training in smart traffic light exercise"),
    user=User1)

session.add(event1)
session.commit()

volunteer1 = Volunteer(
    name="Raymond Hu",
    attuid="rh4570",
    event=event1,
    user=User1)

session.add(volunteer1)
Пример #15
0
)
session.add(User1)
session.commit()
print User1.name

# City info for San Francisco
city1 = City(user_id=1, name="San Francisco", state="California")
session.add(city1)
session.commit()

event1 = Event(
    user_id=1,
    name="Droidcon San Francisco 2016",
    description="The droidcon conferences around the world support the \
	Android platform and create a global network for developers and \
	companies. We offer best-in-class presentations from leaders in all \
	parts of the Android ecosystem, including core development, embedded \
	solutions augmented reality, business solutions and games.",
    city=city1,
    event_date=date(2016, 3, 17),
    event_url="http://sf.droidcon.com/",
    image_url="https://embed.gyazo.com/11e1eaa28bf28afaa3a1f235b5f985e6.png")
session.add(event1)
session.commit()

event2 = Event(
    user_id=1,
    name="SF Android User Group",
    description="We are an interactive group of Android developers and \
	contractors discussing trends in technology, business, and job outlook.",
    city=city1,
    event_date=date(2015, 10, 27),
Пример #16
0
# declaratives can be accessed through a DBSession instance
Base.metadata.bind = engine

DBSession = sessionmaker(bind=engine)
# A DBSession() instance establishes all conversations with the database
# and represents a "staging zone" for all the objects loaded into the
# database session object. Any change made against the objects in the
# session won't be persisted into the database until you call
# session.commit(). If you're not happy about the changes, you can
# revert all of them back to the last commit by calling
# session.rollback()
session = DBSession()

event1 = Event(name="AAKAR Delhi",
               location="Delhi",
               month="August",
               year="2017-18",
               image="aakardelhi.png")
session.add(event1)
session.commit()

event2 = Event(name="AAKAR Ahemdabad",
               location="Ahemdabad",
               month="September",
               year="2017-18",
               image="aakarahm.png")
session.add(event2)
session.commit()

event3 = Event(name="AAKAR Kolkata",
               location="Kolkata",