Exemple #1
0
class UserEdit(View):

    template_name = 'templates/admin/user/edit.html'
    __context = Context()
    __user = UserModule()
    __correlation_id = None

    @login_if_not_authenticated_or_no_permission("manage_settings")
    def get(self, request, user_id):

        self.__correlation_id = request.META[
            "X-Correlation-ID"] if "X-Correlation-ID" in request.META else ""
        user = self.__user.get_one_by_id(user_id)

        if not user:
            raise Http404("User not found.")

        self.__context.autoload_options()
        self.__context.autoload_user(
            request.user.id if request.user.is_authenticated else None)
        self.__context.push({
            "page_title":
            _("Edit User · %s") % self.__context.get(
                "app_name", os.getenv("APP_NAME", "Silverback")),
            "user":
            user
        })

        return render(request, self.template_name, self.__context.get())
    def get(self, request, token):

        self.__correlation_id = request.META[
            "X-Correlation-ID"] if "X-Correlation-ID" in request.META else ""
        self.__user = UserModule()
        self.__context = Context()
        self.__option_entity = OptionEntity()

        if not self.__user.check_register_request(token):
            messages.error(
                request,
                _("Register token is expired or invalid, Please contact system administrator!"
                  ))
            return redirect("app.web.login")

        self.__context.autoload_options()
        self.__context.push({
            "page_title":
            _("Register · %s") % self.__context.get(
                "app_name", os.getenv("APP_NAME", "Silverback")),
            "register_request":
            self.__user.get_register_request_by_token(token)
        })

        return render(request, self.template_name, self.__context.get())
 def __init__(self):
     self.__request = Request()
     self.__response = Response()
     self.__helpers = Helpers()
     self.__form = Form()
     self.__user = UserModule()
     self.__logger = self.__helpers.get_logger(__name__)
     self.__form.add_validator(ExtraRules())
    def get(self, request, token):

        self.__user = UserModule()

        if not self.__user.check_register_request(token):
            messages.error(request, _("Register token is expired or invalid, Please contact system administrator!"))
            return redirect("app.web.login")

        self.autoload_options()
        self.context_push({
            "page_title": _("Register · %s") % self.context_get("app_name", os.getenv("APP_NAME", "Silverback")),
            "register_request": self.__user.get_register_request_by_token(token)
        })

        return render(request, self.template_name, self.context_get())
Exemple #5
0
    def get(self, request):

        self.__context = Context()
        self.__user = UserModule()
        self.__correlation_id = request.META[
            "X-Correlation-ID"] if "X-Correlation-ID" in request.META else ""
        self.__context.autoload_options()
        self.__context.autoload_user(
            request.user.id if request.user.is_authenticated else None)
        self.__context.push({
            "page_title":
            _("Add a User · %s") %
            self.__context.get("app_name", os.getenv("APP_NAME", "Silverback"))
        })

        return render(request, self.template_name, self.__context.get())
Exemple #6
0
class UserAdd(View):

    template_name = 'templates/admin/user/add.html'
    __context = Context()
    __user = UserModule()
    __correlation_id = None

    @login_if_not_authenticated_or_no_permission("manage_settings")
    def get(self, request):

        self.__correlation_id = request.META[
            "X-Correlation-ID"] if "X-Correlation-ID" in request.META else ""
        self.__context.autoload_options()
        self.__context.autoload_user(
            request.user.id if request.user.is_authenticated else None)
        self.__context.push({
            "page_title":
            _("Add a User · %s") %
            self.__context.get("app_name", os.getenv("APP_NAME", "Silverback"))
        })

        return render(request, self.template_name, self.__context.get())
Exemple #7
0
    def get(self, request, user_id):

        self.__context = Context()
        self.__user = UserModule()
        self.__correlation_id = request.META[
            "X-Correlation-ID"] if "X-Correlation-ID" in request.META else ""
        user = self.__user.get_one_by_id(user_id)

        if not user:
            raise Http404("User not found.")

        self.__context.autoload_options()
        self.__context.autoload_user(
            request.user.id if request.user.is_authenticated else None)
        self.__context.push({
            "page_title":
            _("Edit User · %s") % self.__context.get(
                "app_name", os.getenv("APP_NAME", "Silverback")),
            "user":
            user
        })

        return render(request, self.template_name, self.__context.get())
Exemple #8
0
 def __init__(self):
     self.__user = UserModule()