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
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
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
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
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
def new_activities(person_id): p = PersonInfo.query.get(person_id) if request.method == 'POST': if request.form['date']: ac_date = datetime.strptime(request.form['date'], '%m/%d/%Y') else: ac_date = None ac_content = request.form['activity'].replace('\r\n', '<br/>') actv = Activities(ac_date, ac_content) print('----------------------------------') print(ac_date, request.form['activity']) p.activities.append(actv) db.session.add(actv) db.session.commit() return render_template('activities.html', p=p) else: return render_template('new_activities.html', p=p)
def create_activity(token_info): data = request.get_json() start = dp.isoparse(data["activity_start"]).astimezone(tz.UTC) end = dp.isoparse(data["activity_end"]).astimezone(tz.UTC) new_activities = Activities( name=data["name"], user_id=token_info["public_id"], activity_start=start, activity_end=end, category_id=data["category_id"], ) database.db_session.add(new_activities) database.db_session.commit() return jsonify({"message": "new activity record created"})
def create_activity(token_info: dict) -> Tuple[Response, int]: data = request.get_json() start = _parse_to_utc_iso8610(data["activity_start"]) end = _parse_to_utc_iso8610(data["activity_end"]) activity_id = str(uuid.uuid4()) category = Categories.get_specific_category(data["category_id"]) duration = _calculate_duration_in_mins(start, end) Activities( activity_id=activity_id, name=data["name"], user_id=token_info["public_id"], activity_start=start, activity_end=end, category=category, duration=duration, ).save() return jsonify({"activity_id": activity_id}), 200
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