示例#1
0
 def __init__(self, *args, **kwargs):
     kwargs['csrf_enabled'] = False
     Form.__init__(self, *args, **kwargs)
     self.answer = None
     self.question_id = None
     self.userid1 = None
     self.userid2 = None
示例#2
0
 def __init__(self, current_user, current_problem, *args, **kwargs):
     if current_user.is_authenticated():
         self.current_user_id = current_user.id
     else:
         self.current_user_id = None
     self.current_problem_id = current_problem.id
     Form.__init__(self, *args, **kwargs)
示例#3
0
 def __init__(self, user=None):
     Form.__init__(self)
     if user:
         self.user = user
         self.first_name.data = self.user.first_name
         self.last_name.data = self.user.last_name
         self.email.data = self.user.email
示例#4
0
 def __init__(self, *args, **kwargs):
     Form.__init__(self, *args, **kwargs)
     # Possible groups a user can choose from are loaded into the permitted select
     groups = Group.query.filter(User.user_name == current_user.user_name, Group.group_name != "private").all()
     group_private = Group.query.filter(Group.group_name == "private").all()
     # Put the private group first
     self.permitted.choices = [(group.group_id, group.group_name) for group in group_private + groups]
     self.image_obj = None
示例#5
0
def delete_profile():
    form = Form()
    if form.validate():
        db.session.delete(current_user)
        db.session.commit()
        flash('Profile deleted successfully.')
        return redirect(url_for('bro.index'))
    abort(BAD_REQUEST_STATUS_CODE)
示例#6
0
 def __init__(self, *args, **kwargs):
     """Initialize the ChangeDateAndDepartmentForm object"""
     Form.__init__(self, *args, **kwargs)
     self.ds = None
     self.dept_id = None
     self.department.choices = [
         (dept.id, dept.name) for dept in Department.query.all()
     ]
示例#7
0
 def __init__(self, member=None):
     Form.__init__(self)
     self.roles.choices = [(role.id, role.name) for role in Role.query.all()]
     self.member = member
     if self.member:
         self.first_name.data = self.member.first_name
         self.last_name.data = self.member.last_name
         self.email.data = self.member.email
         self.roles.data = [role.id for role in self.member.roles]
示例#8
0
文件: views.py 项目: xmnlab/pysos
    def __init__(self, *args, **kwargs):
        """

        :param args:
        :param kwargs:
        :return:
        """
        Form.__init__(self, *args, **kwargs)
        self.user = None
示例#9
0
    def __init__(self, place, *a, **kw):
        Form.__init__(self, *a, **kw)
        self.place = place
        self.level.choices = [(t.short_name, t.name) for t in models.PlaceType.all()]

        # Ensure that there are at least 5 empty slots
        empty_slots = sum(1 for role in self.data['roles'] if not role['name'].strip())
        for i in range(5-empty_slots):
            self.roles.append_entry()
示例#10
0
文件: forms.py 项目: LACMTA/centroids
    def __init__(self, *args, **kwargs):
        Form.__init__(self, *args, **kwargs)
        self.stop_id = kwargs['stop_id']
        self.ip = kwargs['ip']
        self.timestamp = kwargs['timestamp']

        if kwargs['stop_name']:
            self.stop_name = kwargs['stop_name']
        else:
            self.stop_name = "glargh"
示例#11
0
def delete(id):
    item = Transcript.query.get_or_404(id)
    form = Form()

    if form.validate_on_submit():
        db.session.delete(item)
        db.session.commit()
        return redirect_for('transcript.index')

    return render_template('transcript/delete.html', item=item, form=form)
示例#12
0
def delete(id):
    item = CanonItem.query.get_or_404(id)
    form = Form()

    if form.validate_on_submit():
        db.session.delete(item)
        db.session.commit()

        return redirect_for('canon.index')

    return {'item': item, 'form': form}
示例#13
0
 def __init__(self, user=None, *args, **kwargs):
     Form.__init__(self, *args, **kwargs)
     if user:
         self.email.data = user.email
         self.name.data = user.name
         self.nickname.data = user.nickname
         self.role_id.data = user.role_id
         self.address.data = user.address
         self.phone.data = user.phone
         self.timezone.data = user.timezone
         self.lang.data = user.lang
示例#14
0
def delete(id):
    item = Salad.query.get_or_404(id)
    form = Form()

    if form.validate_on_submit():
        item.delete()
        db.session.commit()

        return redirect_for('salad.index')

    return render_template('salad/delete.html', item=item, form=form)
示例#15
0
 def __init__(self, post=None, *args, **kwargs):
     Form.__init__(self, *args, **kwargs)
     self.category_id.choices = Category.get_list()
     if post:
         self.id = kwargs.get("id") if kwargs.get("id") else 0
         self.title.data = post.title
         self.body.data = post.body
         self.extra_body.data = post.extra_body
         self.anonymous.data = post.anonymous
         self.category_id.data = post.category_id
         self.cover_picture_id.data = post.cover_picture_id
示例#16
0
def delete(id):
    page = WikiPage.query.get_or_404(id)
    form = Form()

    if form.validate_on_submit():
        db.session.delete(page)
        db.session.commit()

        return redirect_for('wiki.index')

    return {'page': page, 'form': form}
示例#17
0
def delete(id):
    item = Salad.query.get_or_404(id)
    form = Form()

    if form.validate_on_submit():
        item.delete()
        db.session.commit()

        return redirect_for('salad.index')

    return {'item': item, 'form': form}
示例#18
0
def unfriend(id):
    form = Form()
    if form.validate():
        profile = Profile.query.get_or_404(id)
        try:
            current_user.unfriend(profile)
        except ValueError:
            abort(BAD_REQUEST_STATUS_CODE)
        db.session.commit()
        return redirect(url_for('bro.view_profile', id=id))
    abort(BAD_REQUEST_STATUS_CODE)
示例#19
0
文件: view.py 项目: 2008820/myprojeck
def index():
    form = Form()
    if form.validate_on_submit():
        userid = request.form["user"]
        if verify_user(userid):
            return redirect("/bookfood")
        else:
            flash("请注册")
            return render_template("login.html", form=form)
    else:
        return render_template("login.html", form=form)
示例#20
0
    def __init__(self, *args, **kwargs):
        Form.__init__(self, *args, **kwargs)

        # Load subjects and users from database to populate select options
        users = ["All Users"] + [user.user_name for user in User.query.order_by(User.user_name).all()]

        image_query = Image.query.group_by(Image.subject).order_by(Image.subject).all()
        subjects = ["All Subjects"] + [image.subject for image in image_query]

        self.subject.choices = [["No Subjects", "Any Subject"]] + list(zip(subjects, subjects))
        self.user.choices = [["No Users", "Any User"]] + list(zip(users, users))
示例#21
0
def delete_friend_request(id):
    form = Form()
    if form.validate_on_submit():
        profile = Profile.query.get_or_404(id)
        try:
            current_user.delete_incoming_request(profile)
        except ValueError:
            abort(BAD_REQUEST_STATUS_CODE)
        db.session.commit()
        return redirect(url_for('bro.view_profile', id=id))
    abort(BAD_REQUEST_STATUS_CODE)
示例#22
0
def delete(title):
    page = WikiPage.query.filter(WikiPage.title == title).first_or_404()
    form = Form()

    if form.validate_on_submit():
        db.session.delete(page)
        db.session.commit()

        return redirect_for('wiki.index')

    return render_template('wiki/delete.html', page=page, form=form)
示例#23
0
def logout():
    form = Form()
    if form.validate_on_submit():
        logout_user()
        if 'redirect_to' in session:
            redirect_to = session['redirect_to']
            session.pop('redirect_to', None)
        flash(gettext('Signed out successfully.'))
    else:
        flash(gettext('Invalid Action'), 'error')

    return redirect(url_for('index'))
示例#24
0
def index():
    form = Form()
    if form.validate_on_submit():
        send(
            dest_ip=form.destination_ip.data,
            port=form.port.data,
            src_ip=form.source_ip.data,
            payload=form.payload.data,
            count=form.count.data
        )
        return "Sent %d packet(s)." % form.count.data
    return render_template("index.html", form=form)
示例#25
0
    def _delete(self, sc_id, transaction, changed_by):
        where = {"sc_id": sc_id}
        signoff = self.signoffs_table.select(where, transaction)
        if not signoff:
            return Response(status=404, response="{} has no signoff to revoke".format(changed_by))

        form = Form(request.args)
        if not form.validate():
            self.log.warning("Bad input: %s", form.errors)
            return Response(status=400, response=json.dumps(form.errors))

        self.signoffs_table.delete(where, changed_by=changed_by, transaction=transaction)
        return Response(status=200)
示例#26
0
文件: forms.py 项目: creighton/xci
 def __init__(self, *args, **kwargs):
     Form.__init__(self, *args, **kwargs)
     obj = kwargs.get('obj', False)
     if obj:
         self.title.data = obj.get('title', None)
         self.description.data = obj.get('description', None)
         self.uri.data = obj.get('uri', None)
         # only json dump if there's a value... cuz json'll make it null
         # and then cause it to be saved later as 'ids':'null'
         self.ids.data = json.dumps(obj.get('ids', None)) if obj.get('ids', None) else obj.get('ids', None)
         self.ctype.data = obj.get('type', None)
         self.levels.data = json.dumps(obj.get('levels', None)) if obj.get('levels', None) else obj.get('levels', None)
         self.relations.data = json.dumps(obj.get('relations', None)) if obj.get('relations', None) else obj.get('relations', None)
         self.linked_content.data = json.dumps(obj.get('linked_content', None)) if obj.get('linked_content', None) else obj.get('linked_content', None)
示例#27
0
 def __init__(self, page=None):
     Form.__init__(self)
     self.page = page
     self.templates.choices = [(t.id, t.name) for t in Template.query.all()]
     self.templates.coerce = int
     if self.page:
         self.slug.data = page.slug
         self.title.data = page.title
         self.description.data = page.description
         self.content.data = page.content
         self.login_required.data = page.login_required
         self.show_in_nav.data = page.show_in_nav
         self.templates.data = page.template_id
         self.header_image.data = page.header_image
示例#28
0
    def validate(self):
        if not Form.validate(self):
            return False
        
        _c_id = self.c_id.data
        _c_type = self.c_type.data
        _sem = self.sem.data
        _cred = self.cred.data

        rv = True

        courses = {}
        with open("files/courses.json", "r") as f:
            courses = json.load(f)
        if str(_c_id) in courses:
            self.c_id.errors.append(
                "Course already registered."
                )
            rv = False

        limit = {"UG": 8, "PG": 4}
        lim = limit[_c_type]
        if _sem not in xrange(1, lim+1):
            self.sem.errors.append(
                "Incorrect sem. Should be between 1-" + str(lim) + " for " + _c_type
                )
            rv = False

        if _cred not in xrange(1, 5):
            self.cred.errors.append(
                "Incorrect credits, should be between 1 and 4 only."
                )
            rv = False

        return rv
示例#29
0
 def validate(self):
     if not Form.validate(self):
         # for field, errors in self.errors.items():
         #     print field, errors
         return False
     else:
         return True
示例#30
0
文件: forms.py 项目: jpittis/remindme
    def validate(self):
        if not Form.validate(self):
            return False

        if len(self.phone.data) != 10 or not self.phone.data.isdigit():
            self.phone.errors.append('Phone number must be 10 digits, without other characters.')
            return False
示例#31
0
 def __init__(self, *args, **kwargs):
     Form.__init__(self, *args, **kwargs)
示例#32
0
 def __init__(self, place=None, *a, **kw):
     Form.__init__(self, *a, **kw)
     self._place = place
示例#33
0
文件: forms.py 项目: oggnik/acm-hscc
 def __init__(self, *args, **kwargs):
     """Initialize the form"""
     Form.__init__(self, *args, **kwargs)
示例#34
0
文件: views.py 项目: kuujakke/kolbe
def index():
    return render_template('tags/index.html',
                           title="Tags",
                           tags=Tag.get_all_tags(Tag()),
                           form=Form(secret_key=app.config['SECRET_KEY']))
示例#35
0
 def __init__(self, *args, **kwargs):
     Form.__init__(self, *args, **kwargs)
     self.user = None
示例#36
0
 def __init__(self, obj=None, prefix='', **kwargs):
     Form.__init__(
         self, obj=obj, prefix=prefix, **kwargs
     )
     self._obj = obj
示例#37
0
 def __init__(self, original_nickname, *args, **kwargs):
     Form.__init__(self, *args, **kwargs)
     self.original_nickname = original_nickname
示例#38
0
 def __init__(self, *args, **kwargs):
     Form.__init__(self, *args, **kwargs)
     if not self.next.data:
         self.next.data = get_redirect_target() or ''
示例#39
0
 def __init__(self, place, *a, **kw):
     Form.__init__(self, *a, **kw)
     self._place = place
     self._setup_booth_options()