示例#1
0
def create_event(form_data, organization_id):
    event = Event(name=form_data["name"],
                  date=form_data["date"],
                  summary=form_data["summary"],
                  location=form_data["location"],
                  organization_id=organization_id)
    event.presenters = get_users(form_data["presenters"])

    return event
示例#2
0
 def setUp(self):
     db.create_all()
     db.session.add(
         Event(id=1,
               eb_id='5',
               name='Check',
               image='https://png.pngtree.com/svg/20161216/5935bddf9c.png',
               desc='Check check',
               html='<p>Check check</p>',
               url='https://png.pngtree.com/svg/20161216/5935bddf9c.png',
               address='Check city, Atlanta',
               lat=0,
               lng=0))
     db.session.commit()
示例#3
0
def add_event():
    request_json = request.get_json()
    auth_token = request_json['auth_token']
    user = User.verify_auth_token(auth_token)
    if not user:
        return json.dumps({'status': 0, 'error': "Authentication Failed"})
    elif not user.isMaster:
        return json.dumps({'status': 0, 'error': "Access Denied"})
    else:
        lat = request_json['gps'][0]
        lon = request_json['gps'][1]
        user_id = user.id
        new_event = Event(lat=lat, lon=lon, user_id=user_id)
        db.session.add(new_event)
        db.session.commit()
        return json.dumps({'status': 1})
示例#4
0
def add_event(request):
    if request.method == 'POST':

        id_reservation = request.POST.get('id_reservation')
        title = request.POST.get('title')

        if title is None or id_reservation is None:
            return JsonResponse({
                'id_reservation': id_reservation,
                'title': title
            })

        event = Event()
        event.id_reservation = id_reservation
        event.title = title

        event.save()

    else:
        return JsonResponse({'Response': 'use POST'})
示例#5
0
def add_custom_event():
    data = request.json
    errors = []
    event_description = data['event_description']
    event_details = data['event_details']
    event_picture_url = Picture.query.get(randint(1, 37)).url
    data['event_picture_url'] = event_picture_url
    custom_event = Event(
        name=data['name'],
        event_description=f'{event_description}\n{event_details}',
        host_id=data['host_id'],
        event_date=data['event_date'],
        event_planet=data['event_planet'],
        event_picture_url=event_picture_url,
        category_id=data['category_id'],
        is_featured=True)
    if errors:
        return jsonify(errors)
    db.session.add(custom_event)
    db.session.commit()
    return jsonify(data)
示例#6
0
文件: events.py 项目: gopilot/backend
def create_event():
    user_id = auth.check_token(request.headers.get('session'))

    if not user_id:
        return "Unauthorized request: Bad session token", 401

    user = Organizer.find_id(user_id)

    if not user:
        return "Unauthorized request: User doesn't have permission", 401

    body = request.get_json()
    event = Event()
    event.name = body.get('name')
    event.start_date = dateParser.parse(body.get('start_date'))
    event.end_date = dateParser.parse(body.get('end_date'))
    event.registration_end = dateParser.parse(body.get('registration_end'))
    event.location = body.get('location')
    event.address = body.get('address')
    event.image = body.get('image')
    event.city = body.get('city')
    event.slug = body.get('slug')

    if body.get('price'):
        event.price = int(body.get('price'))

    event.save()

    user.events.append(event)

    user.save()

    if not event.id:
        return "Error creating event", 500

    return event.to_json()
示例#7
0
    def test_execute_event(self):
        mock_model = mock.Mock()
        mock_aws = mock.Mock()

        with self.assertRaises(NotImplementedError):
            Event(mock_model, mock_aws).execute()
  tarkin = User(username = '******', email = '*****@*****.**', avatar_url = 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcQ633qJmSKAVdZul4oWR-f9wB6US_N_bHee2g&usqp=CAU')
  dooku = User(username = '******', email = '*****@*****.**', avatar_url = 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcQALITa_iwn6z77Xr6RMHDJG-0l8pvFYI--tA&usqp=CAU')
  boba = User(username = '******', email = '*****@*****.**', avatar_url = 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcTYj2Rw2Crz24sNcXZ9v9KfnlEZupa_ZdmMKQ&usqp=CAU')
  han = User(username = '******', email = '*****@*****.**', avatar_url = 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcTS9TwNUBH0EbzmUt6OWZ4XhjIsiIQ84jf3tg&usqp=CAU')
  luke = User(username = '******', email = '*****@*****.**', avatar_url = 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcSczQtK1E0AgyUchH_Ov7hj5xHnQr69LT7O2g&usqp=CAU')
  rey = User(username = '******', email = '*****@*****.**', avatar_url = 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcQe0sZYKoaf065ZKjnl4G1qy1qCB6p8CNhQpw&usqp=CAU')

  party = Category(type = 'Surprise Party')
  production = Category(type = 'Live Productions')
  exectution = Category(type = 'Live Executions')
  sport = Category(type = 'Sports')
  tour = Category(type = 'Tours')
  launch = Category(type = 'Product Launches')
  seminar = Category(type = 'Seminars')

  order_66 = Event(name = 'Order 66', event_description = 'Enjoy a fun night at the Jedi Temple! We will all meet outside on the front steps, and then go in and surprise all the younglings!', host_id = 3, event_date = 'May 27, 19BBY @ 21:00', event_planet = 'Corusant', event_picture_url = 'https://i.ytimg.com/vi/lBbQg8r8tdc/maxresdefault.jpg', category_id =  1, is_featured = True)
  podrace = Event(name = 'Boonta Eve Podrace', event_description = 'This is the biggest podrace of the year! Held in and around the Grand Arena in Mos Epa, this is bound to be a race you will not want to miss! Sebabulba is once again gavored to win the race. **Upgrade your ticket to sit with the Tuskan Raiders and try to shoot down the Racers!**', host_id = 4, event_date = '15:00 hours, June 12, 32BBY', event_planet = 'Tatooine', event_picture_url = 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcQoXdjeOE8nKrEu-jWNxg-nCeDGOPjBJXGbkA&usqp=CAU', category_id = 4, is_featured = True)
  death_star = Event(name = 'Death Star Unvieling', event_description = 'Take a trip to the lovely planet of Alderaan, located in the Core Worlds. This planet has many famous people including the Orengas. You will get a front row introduction to the Empires new luxury cruise ship, called the Death Star. It is a state of the art cruise liner that will travel all over the galaxy under control of the great captain Govenor Tarkin.', host_id = 5, event_date = '0:00 hours January 1, 0BBY', event_planet = 'Alderaan', event_picture_url = 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcSFhGRKvL6ZzQAaN-goNpxqwbulV6VFQ1Or1g&usqp=CAU', category_id = 6, is_featured = True)
  geonosis_execution = Event(name = 'Republic Leaders Execution', event_description = 'The evil Senator Amidala and the Jedis Skywalker and Kenobi have been caught!!!!! Their executions have been schedule to be held in the Petranaki Arena. Buy tickets to this execution. 3 high ranking Republic members! Once in a lifetime event!', host_id = 6, event_date = '17:00 hours, June 22, 19BBY', event_planet = 'Geonosis', event_picture_url = 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcSELfkGG_qoGhokNwcwmwSMR5ThNkXXM5iLyA&usqp=CAU', category_id = 3, is_featured = True)
  carbonite = Event(name = 'Carbonite Museum Grand Opening', event_description = 'Come to Cloud City in Bespin for the Grand Opening of the Carbonite Museum! For one night only, our main attraction is the notorious smuggler Han Solo.', host_id = 7, event_date = '20:00 hours, August 12, 3ABY', event_planet = 'Bespin', event_picture_url = 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcTqMzZ4SePebMG1Ff1VM2LVSC_mMCdG_FnVTR6G2eHidEV0RmeGX3Tn8sQpdQ&usqp=CAc', category_id = 5, is_featured = True)
  darth_plagueis = Event(name = 'Squid Lake by the Mon Calamari Ballet at Coruscant Opera House', event_description = 'In the beautiful Uscru District, lies the Wonderful Galaxies Opera House. The Galaxy renound Mon Calamarin Ballet is putting on a production of Squid Lake. If you have never seen a ballet, this is the one to attend! **Upgrade your tickets to sit in the box with Chancellor Palpentine. Who knows, maybe you will learn things the Jedi can\'t teach you!**', host_id = 2, event_date = '21:00 hours, February 1 19BBY', event_planet = 'Corusant', event_picture_url = 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcSWqj-k_7il4cl1r1vfVfACzbntLKR9NEGVcA&usqp=CAU', category_id = 2, is_featured = True)
  kessel = Event(name = 'Kessel Run Tour', event_description = 'Join the legendary smuggler Han Solo on his tour of the Kessel Run! Ride in the Millenium Falcon, flown by Han Solo and his partner Chewie. The tour starts on Kessel and ends sourth of the Si\'Flaata Cluster. The gole is to move spice without getting caught by Imperial Ships. Good Luck and have fun!', host_id = 8, event_date = 'October 27, 10BBY @ 11:00', event_planet = 'Kessel', event_picture_url = 'https://www.thathashtagshow.com/wp-content/uploads/2020/03/chewie-falcon-4.jpg', category_id = 5, is_featured = True)
  jedi = Event(name = 'Seminar at the Jedi Academy', event_description = 'Get a free lesson in exploring the force led by the one and only Luke Skywalker! The man who brought down the Empire. Open to all beings, even if you are not force sensitive. Surprise guests may include Jedi Ghosts!', host_id = 9, event_date = 'July 12, 23ABY @ 12:00', event_planet = 'Corusant', event_picture_url = 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcTZsvsoLWSwy8jxWt21XbIke_y6rKzHkB6zqw&usqp=CAU', category_id = 7, is_featured = True)
  exegol = Event(name = 'Take Back the Galaxy', event_description = 'Calling all pilots. The Galaxy needs us. The last fragments of hope are on Exegol right now trying to defeat the Emperor and the Sith once and for all. Lightspeed to these coordinates and help take down as many ships as possible so we can witness the exectution of Darth Sidious.', host_id = 10, event_date = 'January 3, 35ABY @ 01:00', event_planet = 'Exegol', event_picture_url = 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcS5EYbIK2tggl9gnUXxCs8aO9vg6fjhSVHMEQ&usqp=CAU', category_id = 3, is_featured = True)
  senate = Event(name = 'Senate Meeting', event_description = 'Come one, Come all! This is the very last Galactic Senate assembly before it becomes the first ever Galactic Empire. LIBERTY WILL DIE WITH THUNDEROUS APPLAUSE.', host_id = 2, event_date = 'May 11, 19BBY @ 15:00', event_planet = 'Corusant', event_picture_url = 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcTeSdOBidrXnWDCQEFulZjvNEDpCkZwrEdq0w&usqp=CAU', category_id = 1, is_featured = True)
  event = Event(name = ' ', event_description = ' ', host_id = 1, event_date = ' ', event_planet = ' ', event_picture_url = ' ', category_id = 1, is_featured = True)



  yoda_1 = Picture(url = 'https://twtchr-img.s3-us-west-2.amazonaws.com/starwars/Yoda_1.jpg')
  throne = Picture(url = 'https://twtchr-img.s3-us-west-2.amazonaws.com/starwars/Throne_Room_Battle.jpg')
示例#9
0
def add_event(request):
    if request.user.is_superuser:
        try:
            if request.method == 'POST' and request.FILES['files']:
                uploaded_file_url = []
                fs = FileSystemStorage()
                invalid = []
                for f in request.FILES.getlist('files'):
                    if (f.content_type == 'image/jpeg' or f.content_type
                            == 'image/png') and f.size < 5000001:
                        filename = fs.save(f.name, f)
                        uploaded_file_url.append(fs.url(filename))
                    else:
                        invalid.append(f.name)
                organizer_name = request.POST.get('organizer_name', None)
                try:
                    c = request.POST.get('coordinates', None).split(',')
                    coordinates = '{lat: ' + str(c[0]) + ', lng: ' + str(
                        c[1]) + '}'
                except:
                    coordinates = None
                event_name = request.POST.get('event_name', None)
                descriptions = request.POST.get('descriptions', None)
                city = request.POST.get('city', None)
                organizer_email = request.user.email
                street = request.POST.get('street', None)
                post_code = request.POST.get('post_code', None)
                street_address = request.POST.get('street_address', None)
                country = request.POST.get('country', 'Poland')
                event_date = request.POST.get('event_date',
                                              '') + 'T' + request.POST.get(
                                                  'event_time', '')
                if len(uploaded_file_url) > 0:
                    try:
                        Event(organizer_name=organizer_name,
                              coordinates=coordinates,
                              event_name=event_name,
                              descriptions=descriptions,
                              city=city,
                              organizer_email=organizer_email,
                              street=street,
                              post_code=post_code,
                              street_address=street_address,
                              country=country,
                              event_date=event_date,
                              pictures=json.dumps(uploaded_file_url)).save()
                    except:
                        return render(
                            request, 'backend/add_event.html', {
                                'info':
                                'Nie udało się stworzyć wydarzenia, błędne dane',
                                'api_key': pers.API_KEY
                            })
                    if len(invalid) == 0:
                        return render(
                            request, 'backend/add_event.html', {
                                'uploaded_file_url': uploaded_file_url,
                                'info': "Stworzyłeś wydarzenie",
                                'api_key': pers.API_KEY
                            })
                    else:
                        return render(
                            request, 'backend/add_event.html', {
                                'uploaded_file_url': uploaded_file_url,
                                'info': 'Błędne pliki to: ' + str(invalid),
                                'api_key': pers.API_KEY
                            })
                else:
                    return render(
                        request, 'backend/add_event.html', {
                            'info':
                            'Nie udało się stworzyć wydarzenia, błędne wszystkie pliki',
                            'api_key': pers.API_KEY
                        })
        except MultiValueDictKeyError:
            return render(
                request, 'backend/add_event.html', {
                    'info': 'Nie udało się stworzyć wydarzenia, brak plików',
                    'api_key': pers.API_KEY
                })
        return render(request, 'backend/add_event.html',
                      {'api_key': pers.API_KEY})
    else:
        return JsonResponse({
            'status': 'false',
            'message': 'Admin only'
        },
                            status=403)
示例#10
0
def event(request):
    if request.method == "POST":
        new_event = Event(
            event_description=request.POST.get('event_description'))
        new_event.save()
    return render(request, "backend/events.html")