예제 #1
0
    def render_page(self, screen, user):
        channels = Channel.get_visible_channels_of(user)
        plugin_channels = [c for c in channels if type(c) == PluginChannel]
        bundle_channels = [c for c in channels if type(c) == ChannelBundle]
        """Let admins select channels with the same orientation as the screen orientation """
        plugin_channels = [c for c in plugin_channels if (c.plugin.name == "editor" and c.get_config_param(
            'vertical') and "Portrait" == screen.orientation) or (c.plugin.name == "editor" and not c.get_config_param(
            'vertical') and "Landscape" == screen.orientation) or (c.plugin.name != "editor")]

        subscriptions=user.get_subscriptions_of_owned_screens()
        last_by =   {sub.channel.id:
                    {
                        'user': sub.created_by.readable_name,
                        'channel_name': sub.channel.name,
                        'plugin_channel': hasattr(sub.channel, 'plugin')
                    }
                    for sub in subscriptions if sub.screen.id == screen.id
                }

        return self.renderer.screen_subscriptions(
            screen=screen,
            user=user,
            users=User.select(),
            screen_channels=Channel.get_screens_channels_from(user=user),
            plugin_channels=plugin_channels,
            bundle_channels=bundle_channels,
            subscriptions=subscriptions,
            last_by = last_by,
            plugin_channels_names = {c.id: c.name for c in plugin_channels},
            bundle_channels_names = {c.id: c.name for c in bundle_channels}
        )
예제 #2
0
 def render_page(self):
     u = User.get(self.session['user']['id'])
     screen_status_validity = datetime.now() - timedelta(hours=1)
     return self.renderer.screens(
         screens=Screen.get_visible_screens_of(u),
         buildings=Building.select(),
         user=u,
         users=User.select(),
         channels=Channel.get_screens_channels_from(user=u),
         subscriptions=u.get_subscriptions_of_owned_screens(),
         screen_status_validity=screen_status_validity,
         max_inactivity_period=timedelta(weeks=4))
예제 #3
0
    def runTest(self):
        """ Tries to create duplicate users and checks that no duplication occurs and that it is handled properly
            for the user """
        username = "******"
        fullname = "Test FullName"
        correct_email = "*****@*****.**"
        wrong_emails = [
            "wrongemail", "[email protected]", "vivelété@mail.com",
            "vivel'*****@*****.**", "@"
        ]
        users_before = {repr(user) for user in User.select()}
        # test some wrong email addresses
        for email in wrong_emails:
            post_params = {
                "action": "create",
                "admin": "",
                "super_admin": "",
                "username": username,
                "fullname": fullname,
                "email": email
            }
            assert self.testApp.post("/users", post_params,
                                     status=303).body is not None
            users_after = {repr(user) for user in User.select()}
            assert users_after == users_before

        # test with wrong usernames
        for username in ["a", "ab"]:
            post_params = {
                "action": "create",
                "admin": "",
                "super_admin": "",
                "username": username,
                "fullname": fullname,
                "email": correct_email
            }
            assert self.testApp.post("/users", post_params,
                                     status=303).body is not None
            users_after = {repr(user) for user in User.select()}
            assert users_after == users_before
예제 #4
0
    def render_page(self):
        u = User.get(self.session['user']['id'])
        screen_status_validity = datetime.now() - timedelta(hours=1)

        def get_data_edit_object(screen):
            object = screen.to_dictionary(['name', 'comment', 'location'])
            object['screenid'] = screen.id
            object['mac'] = screen.get_macs_string(
            ) if screen.macs is not None else ''
            object['building-name'] = screen.building.name
            return json.dumps(object)

        return self.renderer.screens(
            screens=Screen.get_visible_screens_of(u),
            buildings=Building.select(),
            user=u,
            highest_permission_level=u.highest_permission_level,
            users=User.select(),
            channels=Channel.get_screens_channels_from(user=u),
            subscriptions=u.get_subscriptions_of_owned_screens(),
            screen_status_validity=screen_status_validity,
            max_inactivity_period=timedelta(weeks=4),
            get_data_edit_object=get_data_edit_object)
예제 #5
0
    def render_page(self, current_user=None, users=None):
        if current_user is None:
            current_user = User.get(self.session['user']['id'])
        if UserPermissions.channel_administrator in current_user.highest_permission_level:
            users = User.select()

        channels = list(Channel.get_visible_channels_of(current_user))

        plugin_channels = []
        bundles = []

        for channel in channels:
            if type(channel) is PluginChannel:
                plugin_channels.append(channel)
            elif type(channel) is ChannelBundle:
                bundles.append(channel)

        return self.renderer.channels(
            plugin_channels=plugin_channels,
            bundles=bundles,
            current_user=current_user,
            users=users,
            activated_plugins=Plugin.selectBy(activated='yes'),
            found_plugins=Plugin.select(NOT(Plugin.q.activated == 'notfound')))
예제 #6
0
파일: users_page.py 프로젝트: UCL-INGI/ICTV
 def render_page(self):
     current_user = User.get(self.session['user']['id'])
     return self.renderer.users(users=User.select(),
                                current_user=current_user,
                                show_reset_button='local'
                                in self.config['authentication'])