# 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
            obj.setdefault(
                'description_en',
                self.create_random_value(schema['description_en']))

        # fullfill earlier_than and later_than validators
        obj['time_advertising_start'] = (
            datetime.utcnow() - timedelta(
                seconds=random.randint(0, 1000000)))
        obj['time_advertising_end'] = (
            datetime.utcnow() + timedelta(
                seconds=random.randint(0, 1000000)))

        # add some number of spots. If not specified different, we default
        # to have a signup, so possibly created signups will have something
        # to have relations to
        obj.setdefault('spots', random.randint(50, 500))
        if obj['spots'] is not None:
            if ('time_register_start' not in obj and
                    'time_register_end' not in obj):
                obj['time_register_start'] = (
                    datetime.utcnow() - timedelta(
                        seconds=random.randint(0, 1000000)))
                obj['time_register_end'] = (
                    datetime.utcnow() + timedelta(
                        seconds=random.randint(0, 1000000)))
            else:
                if ('time_register_start' not in obj or
                        'time_register_end' not in obj):
                    raise BadFixtureException(
                        "Bad fixture: please specify either both "

# 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

            obj.setdefault(
                'description_en',
                self.create_random_value(schema['description_en']))

        # fullfill earlier_than and later_than validators
        obj['time_advertising_start'] = (
            datetime.utcnow() - timedelta(
                seconds=random.randint(0, 1000000)))
        obj['time_advertising_end'] = (
            datetime.utcnow() + timedelta(
                seconds=random.randint(0, 1000000)))

        # add some number of spots. If not specified different, we default
        # to have a signup, so possibly created signups will have something
        # to have relations to
        obj.setdefault('spots', random.randint(50, 500))
        if obj['spots'] is not None:
            if ('time_register_start' not in obj and
                    'time_register_end' not in obj):
                obj['time_register_start'] = (
                    datetime.utcnow() - timedelta(
                        seconds=random.randint(0, 1000000)))
                obj['time_register_end'] = (
                    datetime.utcnow() + timedelta(
                        seconds=random.randint(0, 1000000)))
            else:
                if ('time_register_start' not in obj or
                        'time_register_end' not in obj):
                    raise BadFixtureException(
                        "Bad fixture: please specify either both "

                        "time_register_start and time_register_end or none")