Пример #1
0
def review_gig(id):
    parser = RequestParser()
    parser.add_argument('feedback')
    parser.add_argument('ratings', type=int)
    args = parser.parse_args()
    ratings = UserModule.UserRatings()
    ratings.gig = GigModule.Gig.objects(id=id).first()
    ratings.client = UserModule.User.objects(id=current_identity['id']).first()
    ratings.feedback = args['feedback']
    ratings.count = args['ratings']
    ratings.save()
    return jsonify({'response': 'ratings added'})
Пример #2
0
def change_password():
    parser = RequestParser()
    parser.add_argument('old_password',
                        required=True,
                        help='Old password is required')
    parser.add_argument('new_password',
                        required=True,
                        help='New password is required')
    args = parser.parse_args()
    user = current_identity
    user = UserModule.User.authenticate(user.email, args['old_password'])
    if not user:
        return jsonify({'response': 'old password is invalid'})
    user.encrypt_set_password(args['new_password'])
    user.save()

    return jsonify({'response': 'Password changed'})
Пример #3
0
from datetime import datetime, timedelta

from flask import Flask, jsonify, request
from flask_reqparse import RequestParser

import connector
from models import scalers, task

app = Flask(__name__)
parser = RequestParser()


@app.route('/')
def index():
    return jsonify({"response": "app is running perfectly fine"})


@app.route('/api/tasks', methods=['POST'])
@parser.validate_arguments([{
    "name": "urgency",
    "type": str,
    "source": "json",
    "required": True
}, {
    "name": "instruction",
    "type": str,
    "source": "json",
    "required": True,
}, {
    "name": "params",
    "type": dict,
Пример #4
0
def edit_profile():
    user = current_identity
    parser = RequestParser()
    parser.add_argument('firstname')
    parser.add_argument('lastname')
    parser.add_argument('profilePicture')
    parser.add_argument('city')
    parser.add_argument('state')
    parser.add_argument('country')
    parser.add_argument('bio')
    parser.add_argument('langauges', type=list)
    parser.add_argument('skills', type=list)
    parser.add_argument('portfolioLink', type=list)
    parser.add_argument('portfolio', type=list)
    parser.add_argument('phone_number', type=str)

    args = parser.parse_args()
    for argument in args:
        if argument not in ['portfolioLink', 'portfolio']:
            user[argument] = args[argument]
        elif argument not in ['portfolioLink', 'portfolio']:
            user[argument] = args[argument]
        elif argument == 'portfolio':
            for portfolioObject in args[argument]:
                portfolio = UserModule.UserPortfolio()
                for p in portfolioObject:
                    portfolio[p] = portfolioObject[p]
                user.portfolio.append(portfolio)
        elif argument == 'portfolioLink':
            for portfolioLink in args['portfolioLink']:
                link = UserModule.ProfileLinks()
                for key in portfolioLink:
                    link[key] = portfolioLink[key]
                user.portfolioLinks.append(link)
    profileCompleteness = 45
    if len(user.skills) >= 2:
        profileCompleteness += 10
    if len(user.portfolioLinks) >= 2:
        profileCompleteness += 10
    if len(user.portfolio) >= 2:
        profileCompleteness += 10
    if user.city:
        profileCompleteness += 10
    if user.profilePicture != constants.PROFILE_PICTURE:
        profileCompleteness += 15

    user.profileCompleteness = profileCompleteness
    user.save()
    return jsonify({'jsonify': 'success'})
Пример #5
0
def update_gig():
    user = current_identity
    parser = RequestParser()
    parser.add_argument('objectId', required=True, help='objectId is required')
    parser.add_argument('title', )
    parser.add_argument('description')
    parser.add_argument('price', type=str)
    parser.add_argument('attachments', type=list)
    parser.add_argument('time')
    parser.add_argument('skills', type=list)
    parser.add_argument('categories', type=list)
    parser.add_argument('banners', type=list)

    args = parser.parse_args()
    gig = GigModule.Gig.objects(id=args['objectId']).first()
    for argument in args:
        if argument != args['objectId']:
            gig[argument] = args[argument]

    gig.save()
    return jsonify({'response': 'success'})
Пример #6
0
def post_gig():
    user = current_identity
    parser = RequestParser()
    parser.add_argument('title', required=True, help='title is required')
    parser.add_argument('description', required=True, help='title is required')
    parser.add_argument('price',
                        required=True,
                        help='price is required',
                        type=str)
    parser.add_argument('attachments', type=list)
    parser.add_argument('time', required=True, help='title is required')
    parser.add_argument('skills', required=True, help='skills', type=list)
    parser.add_argument('categories',
                        required=True,
                        help='categories',
                        type=list)
    parser.add_argument('banners', required=True, help='categories', type=list)

    args = parser.parse_args()
    gig = GigModule.Gig()
    for argument in args:
        gig[argument] = args[argument]
    gig.postedBy = UserModule.User.objects(id=user.id).first()
    gig.save()
    return jsonify({'response': 'success'})
Пример #7
0
def signup():
    """
        Used to signup new user
    """
    parser = RequestParser()
    parser.add_argument('firstname',
                        required=True,
                        help='firstname is required')
    parser.add_argument('lastname', required=True, help='lastname is required')
    parser.add_argument('email', required=True, help='email is required')
    parser.add_argument('password', required=True, help='password is required')

    args = parser.parse_args()
    user = UserModule.User()
    user.firstname = args['firstname']
    user.lastname = args['lastname']
    user.email = args['email']
    user.encrypt_set_password(args['password'])
    try:
        user.save()
    except NotUniqueError:
        return jsonify({"error": "email already exists"}), 400

    return jsonify({'jsonify': 'success'})