# Path: script_builder/current_user.py
# def current_user():
#     t = current_thread()
#     if t not in _requests:
#         return None
#     return _requests[t].user


import os
from django.core.exceptions import ValidationError
from django.db import models
from django.utils.translation import ugettext_lazy as _
from guardian.shortcuts import assign_perm
from ordered_model.models import OrderedModel
from collections import defaultdict
from .current_user import current_user





class PermissionedModel(object):

    def save(self, *args, **kwargs):
        super().save(*args, **kwargs)

# Path: script_builder/current_user.py
# def current_user():
#     t = current_thread()
#     if t not in _requests:
#         return None
#     return _requests[t].user


# Path: script_builder/models.py
import os
from django.core.exceptions import ValidationError
from django.db import models
from django.utils.translation import ugettext_lazy as _
from guardian.shortcuts import assign_perm
from ordered_model.models import OrderedModel
from collections import defaultdict
from .current_user import current_user






class PermissionedModel(object):

    def save(self, *args, **kwargs):
        super().save(*args, **kwargs)

        self.assign_perms(current_user())