コード例 #1
0
ファイル: eventApi.py プロジェクト: Tacokeet/TravelApi
def postEvent(request):
    form = request.form

    if request.files['image']:
        file = request.files['image']
        name = str(time.time()).replace(".", "")
        name = name + "." + file.filename.partition(".")[-1]
        file.save(os.path.join('images\events', name))


    event = Event(
        name=form.get('name'),
        category=form.get('category'),
        description=form.get('description'),
        location=form.get('location'),
        startDate=form.get('start_date'),
        startTime=form.get('start_time'),
        endDate=form.get('end_date'),
        endTime=form.get('end_time'),
        owner=form.get('owner'),
        image=name
    )

    persister.persist_object(event)

    return "success"
コード例 #2
0
ファイル: app.py プロジェクト: OverLucker/pbd_kurs
 def dispatch_request(self):
     username = session.pop('username', None)
     if username:
         Event(type=Event.EventType.LOGOUT,
               sender=username,
               date_register=datetime.now()).save()
     return redirect(url_for('login_view'))
コード例 #3
0
def addEventToDatabase():  #member,event,event_Volenteers,Attendance
    from database import Event, Club, Member
    if request.method == 'POST':
        name = request.form['name']
        eventId = request.form['eventId']
        clubId = request.form['clubId']
        event = Event(eventId, name, clubId)
        db.session.add(event)
        db.session.commit()
        event = Event.query.filter_by(eventId=eventId).first()
        club = Club.query.filter_by(id=clubId).first()
        students = Member.query.filter_by(clubId=club.id).all()
        students = [x.email for x in students
                    ]  #list(map(lambda x : x.email, students))
        #print('sending Message', students)
        msg = Message('Event coming up notification.',
                      sender='*****@*****.**',
                      recipients=students)
        #print('Object created!')
        msg.body = "Dear Student\n We have a event coming up from the club" + club.name + "and the event is" + event.name + ".\n We request you to attend it."
        mail.send(msg)
        return 'Event added successfully!!'

    else:
        #Bad Request
        abort(400)
コード例 #4
0
def create_recurring_event():
    cal = googleapiclient.discovery.build('calendar',
                                          'v3',
                                          credentials=credentials)

    event = {
        'summary': "Trail Running",
        'description': "Some description",
        'location': "Outdoors",
        'start': {
            'dateTime': "2018-08-01T14:00:00-07:00",
            'timeZone': "America/Los_Angeles"
        },
        'end': {
            'dateTime': "2018-08-01T14:30:00-07:00",
            'timeZone': "America/Los_Angeles"
        }
    }
    BRENDAN_TEST_CAL_ID = "*****@*****.**"
    g_event = cal.events().insert(calendarId=BRENDAN_TEST_CAL_ID,
                                  body=event).execute()
    test_schedule = Schedule(google_calendar_id=g_event["id"])
    db_event = Event(campus="Carp")
    db_event.schedules.append(test_schedule)
    db.session.add(db_event)
    db.session.commit()
    return "created", 201
コード例 #5
0
ファイル: bd.py プロジェクト: tokidokika/chat-bot
def save_event(d):
    event_data = Event(date=d['date'],
                       decline=d['decline'],
                       links=d['links'],
                       event=d['event_name'],
                       distance=d['distance'],
                       places=d['country'],
                       race_type=d['race_type'])
    session.add(event_data)
    session.commit()
コード例 #6
0
def postEvent(form):
    print("post event", file=sys.stderr)
    event = Event(name=form.get('name'),
                  category=form.get('category'),
                  description=form.get('description'),
                  location=form.get('location'),
                  startDate=func.now(),
                  endDate=func.now(),
                  image=str(int(time.time())))
    persister.persist_object(event)
    return "success"
コード例 #7
0
def save_event(name, n_url, location, kind, date, distances, decline, country):
    event_data = Event(date=date,
                       decline=decline,
                       links=n_url,
                       event=name,
                       distance=distances,
                       places=location,
                       race_type=kind,
                       country=country)
    session.add(event_data)
    session.commit()
コード例 #8
0
def test_db():
    u = User(telegram_id=str(int(time.time())))
    print(u)

    session.add(u)
    for _ in range(7):
        e = Event(date=datetime.now() +
                  timedelta(milliseconds=random.randint(1, 1000)))
        session.add(e)
        u.events.append(e)
    session.commit()

    print(*Event.upcoming_events(session, 2), sep="\n")
コード例 #9
0
ファイル: weconnect.py プロジェクト: ChampBoy/powertoken
def create_new_event(json_event):
    '''
	#helper function to convert json values to proper Db model values
	@param: json_event (from Weconnect). event = {eid, dateStart, activitity_id, didCheckin}
	'''
    startTime = datetime.strptime(json_event["dateStart"], WC_DATE_FMT)
    duration = timedelta(minutes=int(json_event["duration"]))
    endTime = startTime + duration
    newEvent = Event(eid=json_event["eid"],
                     start_time=startTime,
                     end_time=endTime,
                     activity_id=json_event["activityId"],
                     completed=(json_event["didCheckin"] is True))
    return newEvent
コード例 #10
0
ファイル: app.py プロジェクト: MengmengZHANG/weekreport
def createEvent():
    userID = login.current_user.id
    focusedUser = getFocusedUserFromCookies(request.cookies)
    if focusedUser.id != userID:
        return "Not permited."

    date = request.form.get('date')
    content = request.form.get('content')
    event = Event()
    event.userID = userID
    event.date = date
    event.content = content
    db.session.add(event)
    db.session.commit()
    logger.warning("userID = %d, create event, event date = %s" %
                   (userID, date))
    return "Good!"  #todo
コード例 #11
0
ファイル: app.py プロジェクト: OverLucker/pbd_kurs
    def dispatch_request(self):
        username = ''
        password = ''
        if request.method == "POST":
            username = request.form.get('username')
            password = request.form.get('password')

            user = User.login(username, password)
            if user is not None:
                session['username'] = username
                Event(type=Event.EventType.LOGIN,
                      sender=username,
                      date_register=datetime.now()).save()
                return redirect(url_for('event_view'))

        return render_template('login.html',
                               username=username,
                               password=password)
コード例 #12
0
ファイル: app.py プロジェクト: OverLucker/pbd_kurs
    def dispatch_request(self):
        username = session.get('username', None)
        if username is None:
            return redirect(url_for('login_view'))

        user = User.get_by_username(username)
        if request.method == "POST":
            type = request.form.get('type')
            date_register = request.form.get('date_register')
            comment = request.form.get('comment')

            Event(type=type,
                  sender=username,
                  date_register=date_register,
                  comment=comment).save()

            return redirect(url_for('event_view'))

        return render_template('event_add.html', event_types=Event.Type)
コード例 #13
0
def create_event():
    if 'credentials' not in session:
        return "unauthorized", 401
    cal = googleapiclient.discovery.build('calendar',
                                          'v3',
                                          credentials=credentials)
    req_data = request.get_json()
    calendar_id = CAMPUS_CALENDAR[req_data["campus"]]

    attendees = []
    addToGoogleCal = req_data["googleCalChecked"]
    if addToGoogleCal:
        attendees.append(session["email"])

    events = CreateEvent(req_data, attendees).execute()

    user = find_or_create_user(session["email"], session["name"])
    schedules = []

    for event in events:
        google_event = cal.events().insert(calendarId=calendar_id,
                                           body=event).execute()
        schedule = Schedule(google_calendar_id=google_event["id"])
        schedules.append(schedule)

    event = Event(campus=req_data["campus"])
    event.interested_users.append(user)
    event.schedules = schedules

    tags = list(req_data["tags"].keys())
    for t in tags:
        tag = find_or_create_tag(t)
        event.tags.append(tag)
    db.session.add(event)
    db.session.commit()

    return "created", 201
コード例 #14
0
    'body="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essenti',
    tags='qqskldqlksdjklqsdj',
    img_off='klqjdlkqjskdqsldk')

session.add(post1)
session.add(post2)
session.add(post3)
session.add(post4)

print("Posts Done :)")

##############################################################

act1 = Event(
    title='Birthday of the  surf hotel',
    description=
    'body="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essenti',
    home_img='that just for test',
    tags='qsjhjdqsdq')
act2 = Event(
    title='Event test33333',
    description=
    'body="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essenti',
    home_img='that just for test',
    tags='qsjhjdqsdqddd')
act3 = Event(
    title='Event trial version test',
    description=
    'body="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essenti',
    home_img='that just for test',
    tags='qsjhjdssqsdq')
act4 = Event(
コード例 #15
0
def save_event(start_timestamp, lost_timestamp):
    duration = (lost_timestamp - start_timestamp).total_seconds() / 60
    ev = Event(timestamp=start_timestamp, duration=duration)
    with app.app_context():
        db.session.add(ev)
        db.session.commit()
コード例 #16
0
def add_events(s):
    def get_month_txt(num):
        n = int(num)
        if n == 1:
            return "January"
        if n == 2:
            return "February"
        if n == 3:
            return "March"
        if n == 4:
            return "April"
        if n == 5:
            return "May"
        if n == 6:
            return "June"
        if n == 7:
            return "July"
        if n == 8:
            return "August"
        if n == 9:
            return "September"
        if n == 10:
            return "October"
        if n == 11:
            return "November"
        if n == 12:
            return "December"
        
    def commit_or_not(event):
        print(event)
        answer = input("Save? (y/n) ")
        if len(answer) == 0:
            answer = "0"
        is_good = answer[0].lower()
        if is_good == "y":
            s.add(event)
            s.commit()
            print("Event saved")
        elif is_good == "n":
            print("Event not saved")
        else:
            commit_or_not(event)
    while True:
        name = input("name (leave blank if finished): ")
        if name == '':
            break
        year = input("year (4 digit): ")
        month = input("month (2 digit): ").zfill(2)
        month_txt = get_month_txt(month)
        day = input("date (2 digit): ").zfill(2)
        time_start = input("time to start (formatted, like '10:00am'): ")
        time_end = input("time to end (formatted, like '4:00pm'): ")
        is_two_days = input("Is this a two day show? (y/N): ")
        if len(is_two_days) == 0:
            is_two_days = "n"
        if is_two_days[0].lower() == "y":
            days = 2
            show_date = datetime.strptime(f"{day}-{month}-{year}", "%d-%m-%Y")
            show_date2 = show_date + timedelta(days=1)
            month2 = str(show_date2.month).zfill(2)
            month2_txt = get_month_txt(month2)
            day2 = str(show_date2.day).zfill(2)
            time_start2 = input("time to start 2nd day (formatted, like '10:00am'): ")
            time_end2 = input("time to end 2nd day (formatted, like '4:00 pm'): ")
        else:
            days = 1
            month2 = "none"
            day2 = "none"
            time_start2 = "none"
            time_end2 = "none"
        street_number = input("street number: ")
        street_name = input("street name: ")
        city = input("city: ")
        details = input("details (parking, entrance fee, we will be outdoors/indoors...): ")
        new_event = Event(name=name, days=days, 
                            year=year,
                            month=month, month_txt=month_txt, day=day,
                            time_start=time_start, time_end=time_end,
                            month2=month2, month2_txt=month2_txt, day2=day2,
                            time_start2=time_start2, time_end2=time_end2,
                            street_name=street_name,
                            street_number=street_number,
                            city=city,
                            details=details)
        commit_or_not(new_event)
        print()