mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-03 20:02:47 +00:00 
			
		
		
		
	Add form and template for adding a model.
This commit is contained in:
		
							
								
								
									
										75
									
								
								app/contributions/forms.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								app/contributions/forms.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,75 @@
 | 
			
		||||
from flask_wtf import FlaskForm
 | 
			
		||||
from wtforms import (
 | 
			
		||||
    BooleanField,
 | 
			
		||||
    PasswordField,
 | 
			
		||||
    StringField,
 | 
			
		||||
    SubmitField,
 | 
			
		||||
    SelectMultipleField,
 | 
			
		||||
    ValidationError, FieldList, IntegerField
 | 
			
		||||
)
 | 
			
		||||
from wtforms.validators import InputRequired, Email, EqualTo, Length, Regexp
 | 
			
		||||
from app.models import User
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ContributionForm(FlaskForm):
 | 
			
		||||
 | 
			
		||||
    # The id field will be generated on insert.
 | 
			
		||||
    # The user_id will be retrieved from the user who is performing this operation.
 | 
			
		||||
 | 
			
		||||
    # title = db.Column(db.String(64))
 | 
			
		||||
    title = StringField(
 | 
			
		||||
        'Title',
 | 
			
		||||
        validators=[InputRequired(), Length(max=64)]
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    # description = db.Column(db.String(255))
 | 
			
		||||
    description = StringField(
 | 
			
		||||
        'Description',
 | 
			
		||||
        validators=[InputRequired(), Length(max=255)]
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    # version = db.Column(db.String(16))
 | 
			
		||||
    version = StringField(
 | 
			
		||||
        'Version',
 | 
			
		||||
        validators=[InputRequired(), Length(max=16)]
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    # compatible_service_versions = db.Column(ContainerColumn(list, 255))
 | 
			
		||||
    compatible_service_versions = SelectMultipleField(
 | 
			
		||||
        'Compatible Service Versions',
 | 
			
		||||
        choices=["asd", "blub", "bla"]
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    # publisher = db.Column(db.String(128))
 | 
			
		||||
    publisher = StringField(
 | 
			
		||||
        'Publisher',
 | 
			
		||||
        validators=[InputRequired(), Length(max=128)]
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    # publisher_url = db.Column(db.String(512))
 | 
			
		||||
    publisher_url = StringField(
 | 
			
		||||
        'Publisher URL',
 | 
			
		||||
        validators=[InputRequired(), Length(max=512)]
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    # publishing_url = db.Column(db.String(512))
 | 
			
		||||
    publishing_url = StringField(
 | 
			
		||||
        'Publishing URL',
 | 
			
		||||
        validators=[InputRequired(), Length(max=512)]
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    # publishing_year = db.Column(db.Integer)
 | 
			
		||||
    publishing_year = IntegerField(
 | 
			
		||||
        'Publishing year',
 | 
			
		||||
        validators=[InputRequired()]
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    # shared = db.Column(db.Boolean, default=False)
 | 
			
		||||
    shared = BooleanField(
 | 
			
		||||
        'Shared',
 | 
			
		||||
        validators=[InputRequired()]
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    submit = SubmitField()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -1,7 +1,9 @@
 | 
			
		||||
from flask import render_template
 | 
			
		||||
from flask_login import login_required
 | 
			
		||||
from app.decorators import permission_required
 | 
			
		||||
from app.models import Permission
 | 
			
		||||
from . import bp
 | 
			
		||||
from .forms import ContributionForm
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.before_request
 | 
			
		||||
@@ -11,6 +13,11 @@ def before_request():
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@bp.route('')
 | 
			
		||||
@bp.route('', methods=['GET', 'POST'])
 | 
			
		||||
def contributions():
 | 
			
		||||
    pass
 | 
			
		||||
    form = ContributionForm(prefix='contribution-form')
 | 
			
		||||
    return render_template(
 | 
			
		||||
        'contributions/contribute.html.j2',
 | 
			
		||||
        form=form,
 | 
			
		||||
        title='Contribution'
 | 
			
		||||
    )
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user