def advanced(self): """ The advanced layout for the Dashboard is exactly the same as the 'normal' dashboard. The only difference is the items that are loaded and the Breadcrumb Trail """ return render('/default/derived/dashboard.mako')
def edit(self, name, is_new=False): """ Edit a share. Loads the Share Edition Template. Keyword arguments: name -- the share name to load the information from is_new -- indicated if we are adding a share of editing """ log.debug("Editing share " + name) log.debug("Is the Share New? " + str(is_new)) backend = globals()["ShareBackend" + c.samba_lp.get("share backend").title()](c.samba_lp, {}) if c.samba_lp.get("share backend") in self.__supported_backends: if backend.share_name_exists(name) == False and not is_new: log.warning("Share " + name + " doesn't exist in the chosen backend") message = _("Can't edit a Share that doesn't exist") SwatMessages.add(message, "warning") redirect_to(controller='share', action='index') else: c.p = ParamConfiguration('share-parameters') if is_new: c.share = SambaShare() else: c.share = backend.get_share_by_name(name) return render('/default/derived/edit-share.mako') else: message = _("Your chosen backend is not yet supported") SwatMessages.add(message, "critical") redirect_to(controller='share', action='index')
def index(self): """ Point of entry. Loads the Share List Template """ c.current_page = int(request.params.get("page", 1)) c.per_page = int(request.params.get("per_page", 10)) c.filter_name = request.params.get("filter_shares", "") c.share_list = [] if c.samba_lp.get("share backend") in self.__supported_backends: backend = globals()["ShareBackend" + c.samba_lp.get("share backend").title()]( c.samba_lp, {}) if len(c.filter_name) > 0: c.share_list = filter_list(backend.get_share_list(), c.filter_name) c.breadcrumb.add( _("Filtered By") + " " + c.filter_name, request.environ['pylons.routes_dict']['controller'], request.environ['pylons.routes_dict']['action']) else: c.share_list = backend.get_share_list() else: message = _("Your chosen backend is not yet supported") SwatMessages.add(message, "critical") return render('/default/derived/share.mako')
def index(self): c.user_list = self.__manager.user_list c.group_list = self.__manager.group_list c.list_users = True c.list_groups = True return render('/default/derived/account-dashboard.mako')
def index(self): response.headers['Content-type'] = 'text/html; charset=utf-8' c.title = "Samba Web Administration Tool" c.auth = False if self._check_session(): c.auth = True c.DnsDomain = session['DnsDomain']; c.RootDSE = session['RootDSE']; c.SambaVersion = session['SambaVersion']; return render('/index.html')
def index(self): from authkit.permissions import NotAuthenticatedError if not request.environ.has_key('REMOTE_USER'): SwatMessages.add( _("You must be authenticated to perform that action"), "critical") abort(401) # raise NotAuthenticatedError('Not Authenticated') #identity = request.environ.get('repoze.who.identity') #if identity is None: # SwatMessages.add(_("You must be authenticated to perform that action"), "critical") # abort(401) """ The default Dashboard. The entry point for SWAT """ return render('/default/derived/dashboard.mako')
def index(self): from authkit.permissions import NotAuthenticatedError if not request.environ.has_key('REMOTE_USER'): SwatMessages.add(_("You must be authenticated to perform that action"), "critical") abort(401) # raise NotAuthenticatedError('Not Authenticated') #identity = request.environ.get('repoze.who.identity') #if identity is None: # SwatMessages.add(_("You must be authenticated to perform that action"), "critical") # abort(401) """ The default Dashboard. The entry point for SWAT """ return render('/default/derived/dashboard.mako')
def index(self): """ Point of entry. Loads the Share List Template """ c.current_page = int(request.params.get("page", 1)) c.per_page = int(request.params.get("per_page", 10)) c.filter_name = request.params.get("filter_shares", "") c.share_list = [] if c.samba_lp.get("share backend") in self.__supported_backends: backend = globals()["ShareBackend" + c.samba_lp.get("share backend").title()](c.samba_lp, {}) if len(c.filter_name) > 0: c.share_list = filter_list(backend.get_share_list(), c.filter_name) c.breadcrumb.add(_("Filtered By") + " " + c.filter_name, request.environ['pylons.routes_dict']['controller'], request.environ['pylons.routes_dict']['action']) else: c.share_list = backend.get_share_list() else: message = _("Your chosen backend is not yet supported") SwatMessages.add(message, "critical") return render('/default/derived/share.mako')
def index(self): response.headers['Content-type'] = 'text/html; charset=utf-8' #language = request.params.get("language",self.language).strip(); c.language = self.language; c.title = self.Lang.PageTitle c.auth = False base = BaseModel(); c.WorkGroup = None c.Realm = None if base.WorkGroup.strip() != '': c.WorkGroup = base.WorkGroup c.Realm = base.Realm if self._check_session(): c.auth = True c.DnsDomain = session['DnsDomain']; c.RootDSE = session['RootDSE']; c.SambaVersion = session['SambaVersion']; c.language = session['language']; c.AuthRemote = str(base.AuthRemote).lower() return render('/index.html')
def edit(self, name, is_new=False): """ Edit a share. Loads the Share Edition Template. Keyword arguments: name -- the share name to load the information from is_new -- indicated if we are adding a share of editing """ log.debug("Editing share " + name) log.debug("Is the Share New? " + str(is_new)) backend = globals()["ShareBackend" + c.samba_lp.get("share backend").title()]( c.samba_lp, {}) if c.samba_lp.get("share backend") in self.__supported_backends: if backend.share_name_exists(name) == False and not is_new: log.warning("Share " + name + " doesn't exist in the chosen backend") message = _("Can't edit a Share that doesn't exist") SwatMessages.add(message, "warning") redirect_to(controller='share', action='index') else: c.p = ParamConfiguration('share-parameters') if is_new: c.share = SambaShare() else: c.share = backend.get_share_by_name(name) return render('/default/derived/edit-share.mako') else: message = _("Your chosen backend is not yet supported") SwatMessages.add(message, "critical") redirect_to(controller='share', action='index')
def index(self): """ """ return render('/default/derived/help.mako')
def login(self): """ Shows the Login Screen to the user """ return render('/default/base/login-screen.mako')
def group(self, subaction="index", id=-1): id = int(id) group_manager = GroupManager(self.__manager) template = '/default/derived/account.mako' is_new = False c.group_list = self.__manager.group_list c.list_users = False c.list_groups = True if len(c.filter_name) > 0: c.group_list = self.__filter_groups(c.group_list, c.filter_name) if id == -1: is_new = True ## ## Edit a Group ## if subaction == "edit" or subaction == "add": c.p = ParamConfiguration('group-parameters') c.group = group_manager.edit(id, is_new) if c.group is not None: c.user_group_list = self.__manager.get_users_in_group(id) template = "/default/derived/edit-group.mako" else: type = "critical" cause = _("Unkown Reason") if group_manager.has_message(): cause = group_manager.get_message() message = _("Unable to get Group to edit - %s" % (cause)) SwatMessages.add(message, type) ## ## Save the changes made to a Group ## elif subaction == "save" or subaction == "apply" or subaction == "save_add": (new_id, saved) = group_manager.save(id, is_new) if saved: type = "cool" message = _("Sucessfuly saved the Group with the ID %s" % (id)) else: type = "critical" cause = _("Unkown Reason") if group_manager.has_message(): cause = group_manager.get_message() message = _("Error saving the Group with the ID %s: %s" % (id, cause)) SwatMessages.add(message, type) if subaction == "save_add": redirect_to( url_for("with_subaction", controller='account', action="group", subaction="add")) elif subaction == "save": redirect_to(controller='account', action='group') elif subaction == "apply": redirect_to("account_action", action='group', subaction='edit', id=new_id) ## ## Remove a Certain Group ## elif subaction == "remove": removed = group_manager.remove(id) if removed: type = "cool" message = _("Sucessfuly deleted the Group with the ID %s" % (id)) else: type = "critical" cause = _("Unkown Reason") if group_manager.has_message(): cause = group_manager.get_message() message = _("Error deleting the Group with the ID %s - %s" % (id, cause)) SwatMessages.add(message, type) redirect_to(controller='account', action='user') return render(template)
def user(self, subaction="index", id=-1): id = int(id) user_manager = UserManager(self.__manager) template = "/default/derived/account.mako" is_new = False c.user_list = self.__manager.user_list c.list_users = True c.list_groups = False if len(c.filter_name) > 0: c.user_list = self.__filter_users(c.user_list, c.filter_name) if c.filter_status != -1: if c.filter_status == 1: c.user_list = self.__manager.filter_enabled_disabled(True) elif c.filter_status == 0: c.user_list = self.__manager.filter_enabled_disabled(False) if id == -1: is_new = True ## ## Edit a User ## if subaction == "edit" or subaction == "add": c.p = ParamConfiguration('user-account-parameters') c.user = user_manager.edit(id, is_new) if c.user is not None: template = "/default/derived/edit-user-account.mako" else: type = "critical" cause = _("Unkown Reason") if group_manager.has_message(): cause = group_manager.get_message() message = _("Unable to get User to edit - %s" % (cause)) SwatMessages.add(message, type) ## ## Save the changes made to a User ## elif subaction == "save" or subaction == "apply": (new_id, saved) = user_manager.save(id, is_new) if saved: type = "cool" message = _("Sucessfuly saved the User with the ID %s" % (new_id)) else: type = "critical" cause = _("Unkown Reason") if user_manager.has_message(): cause = user_manager.get_message() message = _("Error saving the User with the ID %s: %s" % (new_id, cause)) SwatMessages.add(message, type) if subaction == "save_add": redirect_to( url_for("with_subaction", controller='account', action="user", subaction="add")) elif subaction == "save": redirect_to(controller='account', action='user') elif subaction == "apply": redirect_to("account_action", action='user', subaction='edit', id=new_id) ## ## Remove a Certain User or a List of Users ## elif subaction == "remove": list_uid = variabledecode.variable_decode(request.params).get( "uid", id) ok_list = [] if not isinstance(list_uid, list): list_uid = [list_uid] for uid in list_uid: uid = int(uid) removed = user_manager.remove(uid) if removed: ok_list.append(uid) log.info("Deleted " + str(uid) + " :: success: " + str(removed)) else: SwatMessages.add(user_manager.get_message(), "critical") if len(ok_list) > 0: joined = ", ".join(["%d" % v for v in ok_list]) if len(ok_list) == 1: message = _("The User with the ID %s was deleted sucessfuly" \ % (joined)) else: message = _("The Users IDs [%s] were deleted sucessfuly" \ % (joined)) SwatMessages.add(message) redirect_to(controller='account', action='user') ## ## Disable a User or a List of Users ## elif subaction == "toggle": list_uid = variabledecode.variable_decode(request.params).get( "uid", id) enabled_list = [] disabled_list = [] if not isinstance(list_uid, list): list_uid = [list_uid] for uid in list_uid: uid = int(uid) (toggled, new_status) = user_manager.toggle(uid) if toggled: if new_status == True: disabled_list.append(uid) else: enabled_list.append(uid) else: SwatMessages.add( _("Error toggling User ID %d: %s" % (uid, user_manager.get_message())), "critical") if len(enabled_list) > 0: joined = ", ".join(["%d" % v for v in enabled_list]) message = _( "The following User IDs [%s] were ENABLED successfuly" % (joined)) SwatMessages.add(message) if len(disabled_list) > 0: joined = ", ".join(["%d" % v for v in disabled_list]) message = _( "The following User IDs [%s] were DISABLED successfuly" % (joined)) SwatMessages.add(message) redirect_to(controller='account', action='user') return render(template)
def user(self, subaction="index", id=-1): id = int(id) user_manager = UserManager(self.__manager) template = "/default/derived/account.mako" is_new = False c.user_list = self.__manager.user_list c.list_users = True c.list_groups = False if len(c.filter_name) > 0: c.user_list = self.__filter_users(c.user_list, c.filter_name) if c.filter_status != -1: if c.filter_status == 1: c.user_list = self.__manager.filter_enabled_disabled(True) elif c.filter_status == 0: c.user_list = self.__manager.filter_enabled_disabled(False) if id == -1: is_new = True ## ## Edit a User ## if subaction == "edit" or subaction == "add": c.p = ParamConfiguration('user-account-parameters') c.user = user_manager.edit(id, is_new) if c.user is not None: template = "/default/derived/edit-user-account.mako" else: type = "critical" cause = _("Unkown Reason") if group_manager.has_message(): cause = group_manager.get_message() message = _("Unable to get User to edit - %s" % (cause)) SwatMessages.add(message, type) ## ## Save the changes made to a User ## elif subaction == "save" or subaction == "apply": (new_id, saved) = user_manager.save(id, is_new) if saved: type = "cool" message = _("Sucessfuly saved the User with the ID %s" % (new_id)) else: type = "critical" cause = _("Unkown Reason") if user_manager.has_message(): cause = user_manager.get_message() message = _("Error saving the User with the ID %s: %s" % (new_id, cause)) SwatMessages.add(message, type) if subaction == "save_add": redirect(url_for("with_subaction", controller='account', action="user", subaction="add")) elif subaction == "save": redirect(url(controller='account', action='user')) elif subaction == "apply": redirect(url("account_action", action='user', subaction='edit', id=new_id)) ## ## Remove a Certain User or a List of Users ## elif subaction == "remove": list_uid = variabledecode.variable_decode(request.params).get("uid", id) ok_list = [] if not isinstance(list_uid, list): list_uid = [list_uid] for uid in list_uid: uid = int(uid) removed = user_manager.remove(uid) if removed: ok_list.append(uid) log.info("Deleted " + str(uid) + " :: success: " + str(removed)) else: SwatMessages.add(user_manager.get_message(), "critical") if len(ok_list) > 0: joined = ", ".join(["%d" % v for v in ok_list]) if len(ok_list) == 1: message = _("The User with the ID %s was deleted sucessfuly" \ % (joined)) else: message = _("The Users IDs [%s] were deleted sucessfuly" \ % (joined)) SwatMessages.add(message) redirect(url(controller='account', action='user')) ## ## Disable a User or a List of Users ## elif subaction == "toggle": list_uid = variabledecode.variable_decode(request.params).get("uid", id) enabled_list = [] disabled_list = [] if not isinstance(list_uid, list): list_uid = [list_uid] for uid in list_uid: uid = int(uid) (toggled, new_status) = user_manager.toggle(uid) if toggled: if new_status == True: disabled_list.append(uid) else: enabled_list.append(uid) else: SwatMessages.add(_("Error toggling User ID %d: %s" % (uid, user_manager.get_message())), "critical") if len(enabled_list) > 0: joined = ", ".join(["%d" % v for v in enabled_list]) message = _("The following User IDs [%s] were ENABLED successfuly" % (joined)) SwatMessages.add(message) if len(disabled_list) > 0: joined = ", ".join(["%d" % v for v in disabled_list]) message = _("The following User IDs [%s] were DISABLED successfuly" % (joined)) SwatMessages.add(message) redirect(url(controller='account', action='user')) return render(template)
def no_libs(self): SwatMessages.add(_("Python libraries not found"), "critical") return render("/default/derived/error/no-libs.mako")
def group(self, subaction="index", id=-1): id = int(id) group_manager = GroupManager(self.__manager) template = '/default/derived/account.mako' is_new = False c.group_list = self.__manager.group_list c.list_users = False c.list_groups = True if len(c.filter_name) > 0: c.group_list = self.__filter_groups(c.group_list, c.filter_name) if id == -1: is_new = True ## ## Edit a Group ## if subaction == "edit" or subaction == "add": c.p = ParamConfiguration('group-parameters') c.group = group_manager.edit(id, is_new) if c.group is not None: c.user_group_list = self.__manager.get_users_in_group(id) template = "/default/derived/edit-group.mako" else: type = "critical" cause = _("Unkown Reason") if group_manager.has_message(): cause = group_manager.get_message() message = _("Unable to get Group to edit - %s" % (cause)) SwatMessages.add(message, type) ## ## Save the changes made to a Group ## elif subaction == "save" or subaction == "apply" or subaction == "save_add": (new_id, saved) = group_manager.save(id, is_new) if saved: type = "cool" message = _("Sucessfuly saved the Group with the ID %s" % (id)) else: type = "critical" cause = _("Unkown Reason") if group_manager.has_message(): cause = group_manager.get_message() message = _("Error saving the Group with the ID %s: %s" % (id, cause)) SwatMessages.add(message, type) if subaction == "save_add": redirect(url_for("with_subaction", controller='account', action="group", subaction="add")) elif subaction == "save": redirect(url(controller='account', action='group')) elif subaction == "apply": redirect(url("account_action", action='group', subaction='edit', id=new_id)) ## ## Remove a Certain Group ## elif subaction == "remove": removed = group_manager.remove(id) if removed: type = "cool" message = _("Sucessfuly deleted the Group with the ID %s" % (id)) else: type = "critical" cause = _("Unkown Reason") if group_manager.has_message(): cause = group_manager.get_message() message = _("Error deleting the Group with the ID %s - %s" % (id, cause)) SwatMessages.add(message, type) redirect(url(controller='account', action='user')) return render(template)
def module(self): """ """ c.help_module_name = request.params.get("name") c.help_module_action = request.params.get("action") return render('/default/derived/help.mako')
def about(self): """ """ return render('/default/derived/help/about.mako')