Exemplo n.º 1
0
def importMeetups(request):
    # Import latest meetups from meetup.com, if we didn't import them within the last hour
    log = Log()
    log.description = "Events imported"
    log.action_type = Log.EVENT_IMPORT
    log.save()

    # get all the hashtags from the DB
    hashtags = Hashtag.objects.all().exclude(name = "Meetup")

    # iterate over them all makeing a call to meetups.com for each one and adding results to the database
    for hashtag in hashtags:
      _callMeetupsCom(hashtag)

    return redirect('eventIndex')
Exemplo n.º 2
0
def toggleEventNA(request, event_id):
    event = get_object_or_404(Event, pk = event_id)
    event.is_applicable = not event.is_applicable
    event.save()

    log = Log();
    desc = "Event (id=" + event_id + ") marked as "
    if (event.is_applicable):
        desc = desc + "applicable "
    else:
        desc = desc + "not applicable "
    log.description = desc;
    log.object_id = event_id
    log.action_type = Log.EVENT_UPDATE
    log.save()

    return redirect('events_list.views.index')
Exemplo n.º 3
0
def toggleGroupNA(request, id):
    group = get_object_or_404(Group, pk = id)
    group.is_applicable = not group.is_applicable
    group.save()

    log = Log();
    desc = "Group (id=" + id + ") marked as "
    if (group.is_applicable):
        desc = desc + "applicable "
    else:
        desc = desc + "not applicable "
    log.description = desc;
    log.object_id = id
    log.action_type = Log.GROUP_UPDATE
    log.save()

    events = Event.objects.filter(group = group)
    for event in events:
        event.is_applicable = group.is_applicable
        event.save()

    return redirect('events_list.views.groupIndex')
Exemplo n.º 4
0
def importMembers(request, group_id):
    group = get_object_or_404(Group, pk = group_id)

    # Import members of a given group
    log = Log()
    log.description = "Members imported"
    log.action_type = Log.EVENT_IMPORT
    log.save()

    url = "https://api.meetup.com/2/members?offset=0&format=json&group_id=" + str(group.meetupID) + "&photo-host=public&page=500&sig_id=148657742&key=" + MEETUP_API_KEY
    response = urllib2.urlopen(url)
    result = response.read()

    data = json.loads(result)
    members = data['results']

    for member in members:
        try:
            person = Person.objects.get(meetupID = member['id'])
        except Person.DoesNotExist:
            person = Person()

        try:
            person.meetupID = member['id']
            person.name = member['name']
            person.country = member['country']
            if 'state' in member.keys():
                person.state = member['state']
            person.city = member['city']
            if 'lon' in member.keys():
                person.longitude = member['lon']
            if 'lat' in member.keys():
                person.latitude = member['lat']                
            person.url = member['link']
            if 'bio' in member.keys():
                person.bio = member['bio']
            visited = float(str(member['visited'])[0:-3])
            person.lastVisit = datetime.utcfromtimestamp(visited)
            if 'photo' in member.keys():
                if 'highres_link' in member['photo'].keys():
                    person.largePhoto = member['photo']['highres_link']
                if 'photo_link' in member['photo'].keys():
                    person.photo = member['photo']['photo_link']
                if 'thumb_link' in member['photo'].keys():
                    person.thumbnail = member['photo']['thumb_link']
            person.save()

            if 'topics' in member.keys():
                for topic in member['topics']:
                    try:
                        record = Topic.objects.get(meetupID = topic['id'])
                    except Topic.DoesNotExist:
                        record = Topic()
                    record.urlkey = topic['urlkey']
                    record.name = topic['name']
                    record.meetupID = topic['id']
                    record.save()
                    person.topics.add(record)
            

            person.groups.add(group)
            person.save()
        except:
            print('Unable to save Person object: '), sys.exc_info()[0], sys.exc_info()[1]

    return redirect('groupIndex')