Exemplo n.º 1
0
def add_event(request):
    current_user = request.user
    Event_name = request.POST['Name']
    Event_desc = request.POST['Desc']
    Start_date = request.POST['Start_Date']
    End_date = request.POST['End_Date']
    Max_part = request.POST['Max']
    Max_list = request.POST['Max_List']

    all_mods = User.objects.filter(is_staff=True)
    array = []
    index = 0
    for mod in all_mods:
        array.insert(index, mod)
        index += 1
    ind = random.randrange(0, index)

    event = eventmod.Event(owner=current_user,
                           event_name=Event_name,
                           event_description=Event_desc,
                           event_start_date=Start_date,
                           event_end_date=End_date,
                           max_participants=Max_part,
                           max_waiting_list_size=Max_list,
                           assigned_mod=array[ind])
    event.save()
    return render(request, 'users/create_event.html', {'msg': array[ind]})
Exemplo n.º 2
0
def create(request):
    form = CreateForm()
    if request.method == 'POST':
        form = CreateForm(request.POST)
        if form.is_valid():
            e = emod.Event()
            e.name = form.cleaned_data.get('name')
            e.description = form.cleaned_data.get('description')
            e.start_date = form.cleaned_data.get('start_date')
            e.end_date = form.cleaned_data.get('end_date')
            e.venue = form.cleaned_data.get('venue')
            e.save()
            return HttpResponseRedirect('/event/events/')

    template_vars = {
        'form': form,
    }
    return dmp_render_to_response(request, 'events.create.html', template_vars)
Exemplo n.º 3
0
Arquivo: events.py Projeto: dvnrsn/CHF
def create(request):
    '''Creates an events'''
    form = CreateForm()
    if request.method == 'POST':  # just submitted the form
        form = CreateForm(request.POST)
        if form.is_valid():
            # print('>>>>>>>>>>>>>>>>>> THE FORM IS VALID?')
            u = emod.Event()
            u.name = form.cleaned_data.get('name')
            u.description = form.cleaned_data.get('description')
            u.start_date = form.cleaned_data.get('start_date')
            u.end_date = form.cleaned_data.get('end_date')
            u.venue = form.cleaned_data.get('venue')
            u.save()
            return HttpResponseRedirect('/event/events')

    template_vars = {
        'form': form,
    }
    return dmp_render_to_response(request, 'events.create.html', template_vars)
Exemplo n.º 4
0
# create the venues
venues = []  # to save for use later
for i in range(1, 10):
    o = emod.Venue()
    o.name = 'Venue%i' % i
    o.address = 'Address %i' % i
    o.city = 'City%i' % i
    o.state = 'State%i' % i
    o.zip_code = 'ZipCode%i' % i
    o.save()
    print(o)
    venues.append(o)

# create the events
for i in range(1, 10):
    o = emod.Event()
    o.name = 'Event%i' % i
    o.description = 'Description of the event %i' % i
    o.start_date = datetime.datetime.now()
    o.end_date = datetime.datetime.now()
    o.venue = random.choice(venues)
    o.save()
    # add some areas to the event
    for j in range(1, 4):
        a = emod.Area()
        a.name = 'Area%i' % j
        a.description = 'Description of the area %i' % j
        a.place_number = i * j
        a.event = o
        a.save()
    print(o)
Exemplo n.º 5
0
    def searchMeetup(self, meetup_client_query, max_events):
        meetup_client = meetup_api_client.Meetup(
            api_key='237e2a627822653b453365385e652f67')

        meetup_response = meetup_client.get_open_events(**meetup_client_query)
        meetup_events = []

        for meetup_event in meetup_response.results:
            try:
                meetup_event_description = meetup_event.description
                meetup_event_short_description = meetup_event_description[:self
                                                                          .
                                                                          short_description_length]
                meetup_event_venue = meetup_event.venue
            except AttributeError:
                continue

            if hasattr(meetup_event,
                       "group") and 'category' in meetup_event.group:
                meetup_event_category = self.get_category_from_meetup(
                    meetup_event.group['category']['shortname'])
            else:
                meetup_event_category = "networking"

            if not 'address_2' in meetup_event_venue:
                meetup_event_venue['address_2'] = ''
            if not 'zip' in meetup_event_venue:
                meetup_event_venue['zip'] = ''
            if not 'state' in meetup_event_venue:
                meetup_event_venue['state'] = ''

            meetup_event_address_parts = [
                meetup_event_venue['address_1'],
                meetup_event_venue['address_2'], meetup_event_venue['city'],
                meetup_event_venue['state'], meetup_event_venue['zip']
            ]
            meetup_event_address_parts = [
                value for value in meetup_event_address_parts if value != ''
            ]
            meetup_event_address = ', '.join(meetup_event_address_parts)
            meetup_event_start = datetime.fromtimestamp(
                int(meetup_event.time) / 1000)

            try:
                duration = meetup_event.duration
            except AttributeError:
                duration = 86400000

            meetup_event_end = datetime.fromtimestamp(
                int(meetup_event.time + duration) / 1000)

            try:
                meetup_event_fee = meetup_event.fee['amount']
            except AttributeError:
                meetup_event_fee = 0

            try:
                meetup_price_choice = self.cleaned_data['price']
                if ((meetup_event_fee > 0 and meetup_price_choice == 'free')
                        or (meetup_event_fee >= 10
                            and meetup_price_choice == 'under_10')
                        or (meetup_event_fee >= 20
                            and meetup_price_choice == 'under_20')):
                    continue
            except KeyError:
                pass

            meetup_event_start_date = meetup_event_start.date()
            meetup_event_start_time = meetup_event_start.time()
            meetup_event_end_date = meetup_event_end.date()
            meetup_event_end_time = meetup_event_end.time()

            meetup_events.append(
                models.Event(
                    source_event_id=meetup_event.id,
                    name=meetup_event.name,
                    address=meetup_event_address,
                    street=meetup_event_venue['address_1'],
                    subpremise=meetup_event_venue['address_2'],
                    city=meetup_event_venue['city'],
                    state=meetup_event_venue['state'],
                    zipcode=meetup_event_venue['zip'],
                    latitude=meetup_event_venue['lat'],
                    longitude=meetup_event_venue['lon'],
                    category=meetup_event_category,
                    short_description=meetup_event_short_description.encode(
                        'utf-8').strip(),
                    description=meetup_event_description.encode(
                        'utf-8').strip(),
                    event_url=meetup_event.event_url,
                    start_date=meetup_event_start_date,
                    start_time=meetup_event_start_time,
                    end_date=meetup_event_end_date,
                    end_time=meetup_event_end_time,
                    ticket_price=meetup_event_fee,
                    source_id=3,
                ))

        return meetup_events[:max_events]
Exemplo n.º 6
0
    def searchEventBrite(self, eb_client_query, max_events):
        eb_auth_tokens = {'app_key': 'K4FQTKYHI34GPW6HSS'}
        eb_client = eventbrite.EventbriteClient(eb_auth_tokens)

        #Only get as many events as we need from EventBrite
        eb_client_query['max'] = max_events

        eb_response = eb_client.event_search(eb_client_query)
        eb_events = []

        for eb_event in eb_response['events'][1:]:
            eb_event = eb_event['event']

            try:
                eb_event_venue = eb_event['venue']
            except KeyError:
                continue

            if (len(eb_event_venue['address']) == 0
                    or eb_event_venue['address'] == 'TBA'
                    or eb_event['category'] == 'sales'):
                continue

            eb_event_start = eb_event['start_date'].split()
            eb_event_start_date = datetime.strptime(eb_event_start[0],
                                                    '%Y-%m-%d').date()
            eb_event_start_time = datetime.strptime(eb_event_start[1],
                                                    '%H:%M:%S').time()
            eb_event_end = eb_event['end_date'].split()
            eb_event_end_date = datetime.strptime(eb_event_end[0],
                                                  '%Y-%m-%d').date()
            eb_event_end_time = datetime.strptime(eb_event_end[1],
                                                  '%H:%M:%S').time()

            if (eb_event_start_date > self.cleaned_data['end_date'].date()
                    or eb_event_end_date <
                    self.cleaned_data['start_date'].date()):
                continue

            try:
                eb_event_ticket_price = float(
                    eb_event['tickets'][0]['ticket']['price'].replace(',', ''))

            except KeyError:
                eb_event_ticket_price = 0.00

            try:
                eb_price_choice = self.cleaned_data['price']
                if ((eb_event_ticket_price > 0 and eb_price_choice == 'free')
                        or (eb_event_ticket_price >= 10
                            and eb_price_choice == 'under_10')
                        or (eb_event_ticket_price >= 20
                            and eb_price_choice == 'under_20')):
                    continue
            except KeyError:
                pass

            eb_event_address_parts = [
                eb_event_venue['address'], eb_event_venue['address_2'],
                eb_event_venue['city'], eb_event_venue['region'],
                eb_event_venue['postal_code']
            ]
            eb_event_address_parts = [
                value for value in eb_event_address_parts if value != ''
            ]
            eb_event_address = ', '.join(eb_event_address_parts)
            eb_event_categories = eb_event['category'].split(',')
            eb_event_description = fromstring(
                eb_event['description']).text_content()
            eb_event_short_description = eb_event_description[:self.
                                                              short_description_length]
            try:
                eb_event_title = html.fragment_fromstring(
                    eb_event['title']).text_content()
            except:
                eb_event_title = eb_event['title']

            eb_events.append(
                models.Event(
                    source_event_id=eb_event['id'],
                    name=eb_event_title,
                    address=eb_event_address,
                    street=eb_event_venue['address'],
                    subpremise=eb_event_venue['address_2'],
                    city=eb_event_venue['city'],
                    state=eb_event_venue['region'],
                    zipcode=eb_event_venue['postal_code'],
                    latitude=eb_event_venue['latitude'],
                    longitude=eb_event_venue['longitude'],
                    keywords=eb_event['tags'],
                    category=self.get_category_from_eb(eb_event_categories[0]),
                    short_description=eb_event_short_description.strip(),
                    description=eb_event_description.strip(),
                    event_url=eb_event['url'],
                    start_date=eb_event_start_date,
                    start_time=eb_event_start_time,
                    end_date=eb_event_end_date,
                    end_time=eb_event_end_time,
                    ticket_price=eb_event_ticket_price,
                    source_id=2,
                ))

        return eb_events