aboutsummaryrefslogtreecommitdiff
path: root/app/blueprints/api/tokens.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/blueprints/api/tokens.py')
-rw-r--r--app/blueprints/api/tokens.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/app/blueprints/api/tokens.py b/app/blueprints/api/tokens.py
index fcc22bb..b8da78d 100644
--- a/app/blueprints/api/tokens.py
+++ b/app/blueprints/api/tokens.py
@@ -29,6 +29,8 @@ from wtforms.ext.sqlalchemy.fields import QuerySelectField
class CreateAPIToken(FlaskForm):
name = StringField("Name", [InputRequired(), Length(1, 30)])
+ package = QuerySelectField("Limit to package", allow_blank=True, \
+ get_pk=lambda a: a.id, get_label=lambda a: a.title)
submit = SubmitField("Save")
@@ -70,6 +72,8 @@ def create_edit_token(username, id=None):
access_token = session.pop("token_" + str(id), None)
form = CreateAPIToken(formdata=request.form, obj=token)
+ form.package.query_factory = lambda: Package.query.filter_by(author=user).all()
+
if request.method == "POST" and form.validate():
if is_new:
token = APIToken()