<commit_before>from flask import abort
from flask_restful import Resource, reqparse
from flask_jwt_extended import jwt_required

from zou.app.services import persons_service
from zou.app.utils import auth, permissions


class NewPersonResource(Resource):

    @jwt_required
    def post(self):
        permissions.check_admin_permissions()
        data = self.get_arguments()
        person = persons_service.create_person(
            data["email"],
            auth.encrypt_password("<PASSWORD>"),
            data["first_name"],
            data["last_name"],
            data["phone"]
        )
        return person, 201

    def get_arguments(self):
        parser = reqparse.RequestParser()
        parser.add_argument(
            "email",
            help="The email is required.",
            required=True
        )
        parser.add_argument(
            "first_name",
            help="The first name is required.",
            required=True
        )
        parser.add_argument(
            "last_name",
            help="The last name is required.",
            required=True
        )
        parser.add_argument("phone", default="")
        args = parser.parse_args()
        return args<commit_msg>Allow to set role while creating a person<commit_after>from flask import abort
from flask_restful import Resource, reqparse
from flask_jwt_extended import jwt_required

from zou.app.services import persons_service
from zou.app.utils import auth, permissions


class NewPersonResource(Resource):

    @jwt_required
    def post(self):
        permissions.check_admin_permissions()
        data = self.get_arguments()
        person = persons_service.create_person(
            data["email"],
            auth.encrypt_password("<PASSWORD>"),
            data["first_name"],
            data["last_name"],
            data["phone"],
            role=data["role"]
        )
        return person, 201

    def get_arguments(self):
        parser = reqparse.RequestParser()
        parser.add_argument(
            "email",
            help="The email is required.",
            required=True
        )
        parser.add_argument(
            "first_name",
            help="The first name is required.",
            required=True
        )
        parser.add_argument(
            "last_name",
            help="The last name is required.",
            required=True
        )
        parser.add_argument("phone", default="")
        parser.add_argument("role", default="user")
        args = parser.parse_args()
        return args
{'fraction_non_alphanumeric': 0.09305064782096584, 'fraction_numerical': 0.002355712603062426, 'mean_word_length': 2.047846889952153, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2752024', 'n_tokens_mistral': 668, 'n_tokens_neox': 649, 'n_words': 155}