diff --git a/pagure/forms.py b/pagure/forms.py index 3caad54..ae43bc5 100644 --- a/pagure/forms.py +++ b/pagure/forms.py @@ -195,7 +195,7 @@ class NewGroupForm(wtf.Form): 'Group name *', [wtforms.validators.Required(), wtforms.validators.Length(max=16)] ) - grp_type = wtforms.SelectField( + group_type = wtforms.SelectField( 'Group type', [wtforms.validators.Required()], choices=[(item, item) for item in []] @@ -207,7 +207,7 @@ class NewGroupForm(wtf.Form): drop-down list. """ super(NewGroupForm, self).__init__(*args, **kwargs) - if 'grp_types' in kwargs: - self.grp_type.choices = [ - (grptype, grptype) for grptype in kwargs['grp_types'] + if 'group_types' in kwargs: + self.group_type.choices = [ + (grptype, grptype) for grptype in kwargs['group_types'] ] diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index 5493d41..d0992b0 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -1762,32 +1762,32 @@ def generate_hook_token(session): session.commit() -def get_group_types(session, grp_type=None): +def get_group_types(session, group_type=None): ''' Return the list of type a group can have. ''' query = session.query( model.PagureGroupType ).order_by( - model.PagureGroupType.grp_type + model.PagureGroupType.group_type ) - if grp_type: + if group_type: query = query.filter( - model.PagureGroupType.grp_type == grp_type + model.PagureGroupType.group_type == group_type ) return query.all() -def search_groups(session, pattern=None, grp_name=None, grp_type=None): +def search_groups(session, pattern=None, group_name=None, group_type=None): ''' Return the groups based on the criteria specified. ''' query = session.query( model.PagureGroup ).order_by( - model.PagureGroup.grp_type + model.PagureGroup.group_type ) if pattern: @@ -1798,15 +1798,15 @@ def search_groups(session, pattern=None, grp_name=None, grp_type=None): if grp_name: query = query.filter( - model.PagureGroup.group_name == grp_name + model.PagureGroup.group_name == group_name ) - if grp_type: + if group_type: query = query.filter( - model.PagureGroup.grp_type == grp_type + model.PagureGroup.group_type == group_type ) - if grp_name: + if group_name: return query.first() else: return query.all() diff --git a/pagure/lib/model.py b/pagure/lib/model.py index 923b1b3..0ad6d51 100644 --- a/pagure/lib/model.py +++ b/pagure/lib/model.py @@ -90,7 +90,7 @@ def create_default_status(session): ERROR_LOG.debug('Status %s could not be added', ticket_stat) for grptype in ['user', 'admin']: - grp_type = PagureGroupType(grp_type=grptype) + grp_type = PagureGroupType(group_type=grptype) session.add(grp_type) try: session.commit() @@ -827,14 +827,14 @@ class PagureGroupType(BASE): # so we set the name to something safe for SQL __tablename__ = 'pagure_group_type' - grp_type = sa.Column(sa.String(16), primary_key=True) + group_type = sa.Column(sa.String(16), primary_key=True) created = sa.Column( sa.DateTime, nullable=False, default=datetime.datetime.utcnow) def __repr__(self): ''' Return a string representation of this object. ''' - return 'GroupType: %s' % (self.grp_type) + return 'GroupType: %s' % (self.group_type) class PagureGroup(BASE): @@ -848,9 +848,9 @@ class PagureGroup(BASE): id = sa.Column(sa.Integer, primary_key=True) group_name = sa.Column(sa.String(16), nullable=False, unique=True) - grp_type = sa.Column( + group_type = sa.Column( sa.String(16), - sa.ForeignKey('pagure_group_type.grp_type'), + sa.ForeignKey('pagure_group_type.group_type'), default='user', nullable=False) user_id = sa.Column( diff --git a/pagure/templates/login/admin_groups.html b/pagure/templates/login/admin_groups.html index 4a1e764..970a482 100644 --- a/pagure/templates/login/admin_groups.html +++ b/pagure/templates/login/admin_groups.html @@ -16,7 +16,7 @@

Create a new group

- {{ form.grp_type()|safe }} + {{ form.group_type()|safe }} {{ form.csrf_token }}
diff --git a/pagure/ui/admin.py b/pagure/ui/admin.py index c52852b..a07a760 100644 --- a/pagure/ui/admin.py +++ b/pagure/ui/admin.py @@ -94,14 +94,14 @@ def admin_groups(): """ List of the groups present in the system """ # Add new group if asked - grp_types = [ - grp.grp_type + group_types = [ + grp.group_type for grp in pagure.lib.get_group_types(SESSION) ] # Make sure the admin type is always the last one - grp_types.remove('admin') - grp_types.append('admin') - form = pagure.forms.NewGroupForm(grp_types=grp_types) + group_types.remove('admin') + group_types.append('admin') + form = pagure.forms.NewGroupForm(group_types=group_types) user = pagure.lib.search_user(SESSION, username=flask.g.fas_user.username) if not user: return flask.abort(403) diff --git a/pagure/ui/groups.py b/pagure/ui/groups.py index ed275e6..7626918 100644 --- a/pagure/ui/groups.py +++ b/pagure/ui/groups.py @@ -25,7 +25,7 @@ import pagure.lib @pagure.APP.route('/groups') def group_lists(): ''' List all the groups associated with all the projects. ''' - groups = pagure.lib.search_groups(pagure.SESSION, grp_type='user') + groups = pagure.lib.search_groups(pagure.SESSION, group_type='user') return flask.render_template( 'group_list.html', @@ -37,7 +37,7 @@ def group_lists(): def view_group(group): ''' Displays information about this group. ''' group = pagure.lib.search_groups( - pagure.SESSION, grp_name=group, grp_type='user') + pagure.SESSION, group_name=group, group_type='user') if not group: flask.abort(404, 'Group not found') diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index 585af9f..8e819be 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -882,7 +882,7 @@ def add_user(repo, username=None): @APP.route('//addgroup', methods=('GET', 'POST')) @APP.route('/fork///addgroup', methods=('GET', 'POST')) @cla_required -def add_group(repo, username=None): +def add_group_project(repo, username=None): """ Add the specified group from the project. """ if admin_session_timedout(): @@ -924,7 +924,7 @@ def add_group(repo, username=None): flask.flash('Group could not be added', 'error') return flask.render_template( - 'add_group.html', + 'add_group_project.html', form=form, username=username, repo=repo,