# Path: amivapi/settings.py
# EMAIL_REGEX = '^.+@.+$'
# 
# REDIRECT_URI_REGEX = '^((http://)?localhost[^#]*|https://[^#]+)$'
# 
# Path: amivapi/utils.py
# @contextmanager
# def admin_permissions():
#     """Switch to a context with admin rights and restore state afterwards.
# 
#     Use as context:
#     >> with admin_rights():
#     >>     do_something()
#     """
#     old_admin = g.get('resource_admin')
#     g.resource_admin = True
# 
#     yield
# 
#     if old_admin is not None:  # None means it wasn't set before..
#         g.resource_admin = old_admin


from datetime import date, datetime, timedelta
from os.path import dirname, join
from contextlib import contextmanager
from bson import ObjectId
from eve.methods.post import post_internal
from werkzeug.datastructures import FileStorage
from amivapi.settings import EMAIL_REGEX, REDIRECT_URI_REGEX
from amivapi.utils import admin_permissions
import random
import string
                    return

        raise BadFixtureException("Requested eventsignup creation, but no "
                                  "unique user/event combination is "
                                  "available anymore. Parsed object: %s"
                                  % obj)

    def preprocess_joboffers(self, schema, obj, fixture):
        """Add title to JobOffers to make them valid. """
        obj.setdefault(
            'title_de',
            self.create_random_value(schema['title_de']))
        obj.setdefault(
            'description_de',
            self.create_random_value(schema['description_de']))

    def create_random_value(self, definition):
        """Create a random value for the given cerberus field description."""
        # If there is a list of allowed values, just pick one
        if 'allowed' in definition:
            return random.choice(definition['allowed'])

        t = definition['type']
        if t == 'string':
            minimum_length = 0 if definition.get('empty', True) else 1
            length = random.randint(minimum_length,
                                    definition.get('maxlength', 100))

            if 'regex' in definition:
                letters_and_digits = string.ascii_letters + string.digits

# Path: amivapi/settings.py
# EMAIL_REGEX = '^.+@.+$'
# 
# REDIRECT_URI_REGEX = '^((http://)?localhost[^#]*|https://[^#]+)$'
# 
# Path: amivapi/utils.py
# @contextmanager
# def admin_permissions():
#     """Switch to a context with admin rights and restore state afterwards.
# 
#     Use as context:
#     >> with admin_rights():
#     >>     do_something()
#     """
#     old_admin = g.get('resource_admin')
#     g.resource_admin = True
# 
#     yield
# 
#     if old_admin is not None:  # None means it wasn't set before..
#         g.resource_admin = old_admin


# Path: amivapi/tests/fixtures.py
from datetime import date, datetime, timedelta
from os.path import dirname, join
from contextlib import contextmanager
from bson import ObjectId
from eve.methods.post import post_internal
from werkzeug.datastructures import FileStorage
from amivapi.settings import EMAIL_REGEX, REDIRECT_URI_REGEX
from amivapi.utils import admin_permissions
import random
import string

                    return

        raise BadFixtureException("Requested eventsignup creation, but no "
                                  "unique user/event combination is "
                                  "available anymore. Parsed object: %s"
                                  % obj)

    def preprocess_joboffers(self, schema, obj, fixture):
        """Add title to JobOffers to make them valid. """
        obj.setdefault(
            'title_de',
            self.create_random_value(schema['title_de']))
        obj.setdefault(
            'description_de',
            self.create_random_value(schema['description_de']))

    def create_random_value(self, definition):
        """Create a random value for the given cerberus field description."""
        # If there is a list of allowed values, just pick one
        if 'allowed' in definition:
            return random.choice(definition['allowed'])

        t = definition['type']
        if t == 'string':
            minimum_length = 0 if definition.get('empty', True) else 1
            length = random.randint(minimum_length,
                                    definition.get('maxlength', 100))

            if 'regex' in definition:
                letters_and_digits = string.ascii_letters + string.digits

                if definition['regex'] == EMAIL_REGEX: