Ejemplo n.º 1
0
    def create(self, validated_data):
        activity = Activities(
            name=validated_data['name'],
            venue=validated_data['venue'],
            postcode=validated_data['postcode'],
            agesLower=validated_data['agesLower'],
            agesUpper=validated_data['agesUpper'],
            contactName=validated_data['contactName'],
            contactEmail=validated_data['contactEmail'],
            number=validated_data['number'],
            special=validated_data['special'],
            )
        activity.save()

        if validated_data['owner']:
            usr = User.objects.get(username = validated_data['owner']['username'])
            activity.owner = usr
            activity.save()
            

        for item in validated_data['days']:
            print 'entering day associtaion'
            newDay = act_day(act=activity, day=item['day'], startTime=item['startTime'], endTime=item['endTime'])
            newDay.save()

        for item in validated_data['cats']:
            print 'entering cat associtaion'
            newCat = Categories.objects.get(name=item['cat']['name'])
            newEventCat = act_cat(act=activity, cat=newCat)
            newEventCat.save()                       

        print activity

        return activity
Ejemplo n.º 2
0
 def post(self):
     data = request.json
     people = People.query.filter_by(name=data['people']).first()
     activity = Activities(name=data['name'], people=people)
     activity.save()
     response = {
         'people': activity.people.name,
         'name': activity.name,
         'id': activity.id
     }
     return response
Ejemplo n.º 3
0
 def post(self):
     content = request.json
     person = People.query.filter_by(name=content['person']).first()
     activity = Activities(name=content['name'], person=person)
     activity.save()
     response = {
         'pessoa': activity.person.name,
         'name': activity.name,
         'id': activity.id
     }
     return response
Ejemplo n.º 4
0
    def post(self):
        dates = request.json
        person = Person.query.filter_by(name=dates['person']).first()
        activity = Activities(name=dates['name'],
                              description=dates['description'],
                              person=person)
        activity.save()
        response = {
            'person': activity.person.name,
            'name': activity.name,
            'description': activity.description
        }

        return response
Ejemplo n.º 5
0
    def post(self):
        data = request.json
        person = People.query.filter_by(name=data['person']).first()
        try:
            activitie = Activities(name=data['name'], person=person)
            activitie.save()
            response = {
                'id': activitie.id,
                'person': activitie.person.name,
                'name': activitie.name
            }
        except AttributeError:
            response = {'status': 'error', 'message': 'Person not found'}

        return response
Ejemplo n.º 6
0
def api_create_activities(request,*,activity_name):
    check_admin(request)
    if not activity_name or not activity_name.strip():
        raise APIValueError('name', 'activity_name cannot be empty.')
    
    activity = Activities(creator=request.__user__.id, creator_name=request.__user__.name, name = activity_name.strip())
    yield from activity.save()
    return activity
Ejemplo n.º 7
0
def update(request):
    content = xmlparser.getNews()

    counter = 0
    for activity in content:
        counter += 1
        new_entry = Activities(id=counter,
                    title=activity['title'],
                    eventType=activity['tipo'].split("/")[3],
                    price=getPrice(activity),
                    time=getTime(activity),
                    duration=getDuratrion(getTime(activity), 
                        datetime.strptime(activity['final'].split('.')[0],'%Y-%m-%d %H:%M:%S')),
                    longDuration=longDuration(activity),
                    description=activity['url'],
                    )
        new_entry.save()

    update = lastUpdate(id=1, time=localTime())
    update.save()

    if request is not None:
        return HttpResponseRedirect("/todas")
Ejemplo n.º 8
0
    def create(self, validated_data):
        activity = Activities(
            name=validated_data['name'],
            venue=validated_data['venue'],
            postcode=validated_data['postcode'],
            agesLower=validated_data['agesLower'],
            agesUpper=validated_data['agesUpper'],
            contactName=validated_data['contactName'],
            contactEmail=validated_data['contactEmail'],
            number=validated_data['number'],
            special=validated_data['special'],
        )
        activity.save()

        if validated_data['owner']:
            usr = User.objects.get(
                username=validated_data['owner']['username'])
            activity.owner = usr
            activity.save()

        for item in validated_data['days']:
            print 'entering day associtaion'
            newDay = act_day(act=activity,
                             day=item['day'],
                             startTime=item['startTime'],
                             endTime=item['endTime'])
            newDay.save()

        for item in validated_data['cats']:
            print 'entering cat associtaion'
            newCat = Categories.objects.get(name=item['cat']['name'])
            newEventCat = act_cat(act=activity, cat=newCat)
            newEventCat.save()

        print activity

        return activity