How to use the spam.model.user_get function in spam

To help you get started, we’ve selected a few spam examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lento / spam / spam / controllers / user / main.py View on Github external
def edit(self, user_id, **kwargs):
        """Display a EDIT form."""
        user = user_get(user_id)
        f_edit.value = dict(user_id=user.user_id,
                            user_name_=user.user_name,
                            display_name=user.display_name)
        tmpl_context.form = f_edit
        return dict(title='%s %s' % (_('Edit user:'), user.user_id))
github lento / spam / spam / controllers / user / main.py View on Github external
def post_add_artists(self, proj, category_id, userids):
        """Add artists to a category"""
        session = session_get()
        user = tmpl_context.user
        project = tmpl_context.project
        category = category_get(category_id)
        added = []
        updates = []

        users = [user_get(uid) for uid in userids]
        artists = [Artist(project.id, category, adduser) for adduser in users if
                                    adduser not in project.artists[category]]
        for artist in artists:
            added.append(artist.user.user_id)

            # prepare updates to notify clients
            updates.append(dict(item=artist.user, type='added',
                        topic=TOPIC_PROJECT_ARTISTS,
                        filter='%s-%s' % (project.id, category.id)))

        added = ', '.join(added)

        if added:
            # log into Journal
            msg = '%s %s %s/%s' % (added,
                                   n_('set as artist for:',
github lento / spam / spam / controllers / user / main.py View on Github external
def post_delete(self, user_id):
        """Delete a user."""
        session = session_get()
        user = tmpl_context.user
        deluser = user_get(user_id)

        session.delete(deluser)

        msg = '%s %s' % (_('Deleted user:'), deluser.user_id)

        # log into Journal
        journal.add(user, '%s - %s' % (msg, deluser))

        # notify clients
        updates = [dict(item=deluser, type='deleted', topic=TOPIC_USERS)]
        notify.send(updates)

        return dict(msg=msg, status='ok', updates=updates)
github lento / spam / spam / controllers / user / main.py View on Github external
def get_delete(self, user_id, **kwargs):
        """Display a DELETE confirmation form."""
        user = user_get(user_id)
        f_confirm.custom_method = 'DELETE'
        f_confirm.value = dict(user_id=user.user_id,
                               user_name_=user.user_name,
                               display_name_=user.display_name)
        tmpl_context.form = f_confirm
        return dict(title='%s %s?' % (_('Are you sure you want to delete:'),
                                                                user.user_id))
github lento / spam / spam / controllers / user / main.py View on Github external
def post_add_supervisors(self, proj, category_id, userids):
        """Add supervisors to a category"""
        session = session_get()
        user = tmpl_context.user
        project = tmpl_context.project
        category = category_get(category_id)
        added = []
        updates = []

        users = [user_get(uid) for uid in userids]
        supervisors = [Supervisor(project.id, category, adduser) for adduser in
                        users if adduser not in project.supervisors[category]]
        for supervisor in supervisors:
            added.append(supervisor.user.user_id)

            # prepare updates to notify clients
            updates.append(dict(item=supervisor.user, type='added',
                        topic=TOPIC_PROJECT_SUPERVISORS,
                        filter='%s-%s' % (project.id, category.id)))

        added = ', '.join(added)

        if added:
            # log into Journal
            msg = '%s %s %s/%s' % (added,
                                   n_('set as supervisor for:',
github lento / spam / spam / controllers / user / main.py View on Github external
def remove_artist(self, proj, category_id, user_id):
        """Remove an artist from a category"""
        session = session_get()
        user = tmpl_context.user
        project = project_get(proj)
        category = category_get(category_id)
        remuser = user_get(user_id)
        updates = []

        if remuser in project.artists[category]:
            query = session.query(Artist).filter_by(proj_id=project.id)
            query = query.filter_by(category_id=category.id)
            query = query.filter_by(user_id=remuser.user_id)
            artist = query.one()
            session.delete(artist)

            # prepare updates to notify clients
            updates.append(dict(item=remuser, type='deleted',
                        topic=TOPIC_PROJECT_ARTISTS,
                        filter='%s-%s' % (project.id, category.id)))

            # log into Journal
            msg = '%s %s %s/%s' % (remuser.user_id,
github lento / spam / spam / controllers / user / main.py View on Github external
def remove_from_group(self, user_id, group_id):
        """Remove a user from a group"""
        session = session_get()
        user = tmpl_context.user
        remuser = user_get(user_id)
        group = group_get(group_id)
        updates = []
        
        if remuser in group.users:
            group.users.remove(remuser)
            
            # prepare updates to notify clients
            updates.append(dict(item=remuser, type='deleted',
                        topic=TOPIC_GROUPS, filter=group.group_name))

            # log into Journal
            msg = '%s %s %s' % (remuser.user_id,
                                _('removed from group'),
                                group.group_id)
            journal.add(user, msg)
            notify.send(updates)
github lento / spam / spam / controllers / user / main.py View on Github external
def post_add_to_group(self, group_id, userids):
        """Add users to a group"""
        session = session_get()
        user = tmpl_context.user
        group = group_get(group_id)
        added = []
        updates = []
        
        for uid in userids:
            adduser = user_get(uid)
            if adduser not in group.users:
                group.users.append(adduser)
                added.append(adduser.user_id)
                
                # prepare updates to notify clients
                updates.append(dict(item=adduser, type='added',
                            topic=TOPIC_GROUPS, filter=group.group_name))
        
        added = ', '.join(added)

        if added:
            # log into Journal
            msg = '%s %s %s' % (added,
                                n_('added to group:',
                                   'added to group:', len(added)),
                                group.group_id)
github lento / spam / spam / controllers / user / main.py View on Github external
def remove_admin(self, proj, user_id):
        """Remove an administrator from a project"""
        session = session_get()
        user = tmpl_context.user
        project = tmpl_context.project
        remuser = user_get(user_id)
        updates = []
        
        if remuser in project.admins:
            project.admins.remove(remuser)
            
            # prepare updates to notify clients
            updates.append(dict(item=remuser, type='deleted',
                        topic=TOPIC_PROJECT_ADMINS, filter=project.id))

            # log into Journal
            msg = '%s %s %s' % (remuser.user_id,
                                _('revoked as administrator for:'),
                                project.id)
            journal.add(user, msg)
            notify.send(updates)
github lento / spam / spam / controllers / user / main.py View on Github external
def post_add_admins(self, proj, userids):
        """Add administrators to a project"""
        session = session_get()
        user = tmpl_context.user
        project = tmpl_context.project
        added = []
        updates = []

        for uid in userids:
            adduser = user_get(uid)
            if adduser not in project.admins:
                project.admins.append(adduser)
                added.append(adduser.user_id)
                
                # prepare updates to notify clients
                updates.append(dict(item=adduser, type='added',
                            topic=TOPIC_PROJECT_ADMINS, filter=project.id))
            
        added = ', '.join(added)
        
        if added:
            # log into Journal
            msg = '%s %s %s' % (added,
                                n_('set as administrator for:',
                                   'set as administrators for:', len(added)),
                                project.id)