Exemplo n.º 1
0
def index():
    role_list=[]
    ren_lenth=0
    form = IndexForm()
    zu = Group.query.filter_by(groupname=form.name.data).first()
    if form.validate_on_submit():
        if zu is None :
            flash(u'此群未建立!')
        else:
             ren_list=zu.user.all()
             ren_lenth=len(ren_list)
             if g.user in ren_list:
                for rens in ren_list:
                    role_list.append(rens.role[0])   
             else:
                flash(u'你不属于该群成员!')
                return redirect(url_for('index'))   
    group_list= g.user.group.all()
    position_list=[]
    name_list=[]
    tel_list=[]
    for role in role_list:
        position_list.append(role.position)
        name_list.append(role.name)
        tel_list.append(role.tel)
    return render_template('index.html',
                           title='Home',
                           form=form,
                           position_list=position_list,name_list=name_list,tel_list=tel_list,role_list=role_list,group_list=group_list,zu=zu,ren_lenth=ren_lenth)
Exemplo n.º 2
0
def index():
    form = IndexForm()
    form.car.choices = [(key, key) for key in data]
    if form.validate_on_submit():
        context_dict = {"car": '', "model": '', "run": 0}
        return redirect(url_for('choice', context_dict=context_dict))
    return render_template('index.html', form=form)
Exemplo n.º 3
0
def index():
	user = g.user
	#print(tr_session.get_session)
	
	# recuperer les torrents de l'utilisateur et de lui uniquement !
	torrents_from_db = Torrent.query.filter_by(user = unicode(g.user)).all()
	# this listing will be used to fetch torrents, and after, to check the update of torrents
	listing =list()
	for x in torrents_from_db:
		listing.append(x.hashstring)
	
	# envoi d'un nouveau torrent
	form = IndexForm()
	torrents = client.get_torrents(listing)
	for torrent in torrents:
		torrent_x=TorrentIndex()
		torrent_x.bandwidthpriority=torrent.bandwidthPriority
		torrent_x.status = torrent.status
		torrent_x.torrentname = torrent.name
		torrent_x.progress = float(torrent.progress)
		torrent_x.tor_id = torrent.hashString
		form.torrents.append_entry(torrent_x)
	
	torrent_to_start = False
	if form.validate_on_submit():
		for torrent_un in form.torrents:
			x = client.get_torrent(unicode(torrent_un.tor_id.data))
			# if the torrent is in the listing...
			if torrent_un.bandwidthpriority.data != int(x.bandwidthPriority) and x.hashString in listing:
				app.logger.info('%s priorité intiale %s, finale %s.',x.name,x.bandwidthPriority,torrent_un.bandwidthpriority.data)
				# we update...
				updatebandwidthpriority(x.hashString,torrent_un.bandwidthpriority.data)
				# and we remove the id from the listing -> if we don't do so, torrents bandwidth priority is updated twice for some obscure reason
				# thus staying at the first priority instead of being really updated to the user wish.
				listing.remove(torrent_un.tor_id.data)
		
		if form.torrentseed_file.data.mimetype == 'application/x-bittorrent':
			filename = secure_filename(form.torrentseed_file.data.filename)
			form.torrentseed_file.data.save(os.path.join(basedir + '/tmp', filename))
			f = open(basedir + '/tmp/' + filename)
			torrent_to_start = base64.b64encode(f.read())
		else:
			if form.torrentseed_url.data != '':
				torrent_to_start = form.torrentseed_url.data
		if torrent_to_start:
			# ON ajoute le torrent à transmission
			new_tor = client.add_torrent(torrent_to_start)
			new_tor.start()
			
			app.logger.info('%s demarré et ajouté à la base de données par %s.',new_tor,user)
			
			# on ajoute le torrent à la base de données pour se souvenir à qui il appartient.
			torrent_to_add = Torrent(hashstring=new_tor.hashString,user=unicode(g.user))
			db.session.add(torrent_to_add)
			db.session.commit()
		#except tr.TransmissionError:
		#	app.logger.info(tr.TransmissionError)
		return redirect(redirect_url())
		
	return render_template("index.html", form = form, title = "Home", user = g.user)
Exemplo n.º 4
0
def index():
  form = IndexForm(request.form)
  app.logger.debug("Main page entry")
  flask.session['memos'] = get_memos()
  for memo in flask.session['memos']:
      app.logger.debug("Memo: " + str(memo))
  if form.validate_on_submit():
          app.logger.debug("removed memo")
  return flask.render_template('index.html', form=form)
Exemplo n.º 5
0
def index():
    form = IndexForm(request.form)

    if request.method == 'POST' and form.validate_on_submit():
        return redirect(url_for('getMeasurementInput'))

    return render_template('index.html',
                           form=form,
                           timelineData=measurementDates)
Exemplo n.º 6
0
def index():
    form = IndexForm(request.form)
    app.logger.debug("Main page entry")
    flask.session['memos'] = get_memos()
    for memo in flask.session['memos']:
        app.logger.debug("Memo: " + str(memo))
    if form.validate_on_submit():
        app.logger.debug("removed memo")
    return flask.render_template('index.html', form=form)
Exemplo n.º 7
0
def show_index():
    form = IndexForm()
    if form.validate_on_submit():
        personal = form.personal.data
        mes = form.mes.data
        anio = form.anio.data
        next = request.args.get('next', None)
        if next:
            return redirect(next)
        return "¡Puedes descargar el archivo desde!"
    return render_template("index.html", form=form)
Exemplo n.º 8
0
def parse():
    form = IndexForm(request.form)
    options = dict(font=None, shadow=None, png=None)
    if form.validate():
        fout = StringIO.StringIO()
        fin = form.data['source']
        svg = subprocess.Popen(['/usr/bin/dot', '-Tsvg'], stdin=subprocess.PIPE, stdout=subprocess.PIPE).communicate(input=fin)[0]
        scruffy.transform(svg, fout, options)
        if form.data['type'] == 'png':
            return cairosvg.svg2png(fout)
        return render_template('index.html', form=form, svg=fout.getvalue())
    return render_template('index.html', form=form)
Exemplo n.º 9
0
    def post(self, request):
        form = IndexForm(request.POST)
        if form.is_valid():
            cd = form.cleaned_data
            year_num = int(cd.get('year'))

        week_num = 0
        last_completed_week_num = 0
        last_inprogress_week_num = 0
        yearlist = get_yearlist()
        if year_num in yearlist:
            week_num = 0
            weeklist = get_weeklist(year_num, only_unlocked_picks=True)
            if len(weeklist) > 0:
                week_num = weeklist[-1]
            else:
                year_num = 0
            if year_num:
                db = Database()
                try:
                    for w in weeklist:
                        cr = CalculateResults(db.load_week_data(year_num, w))
                        week_state = cr.get_summary_state_of_all_games()
                        if week_state == FINAL:
                            last_completed_week_num = w
                        elif week_state == IN_PROGRESS:
                            last_inprogress_week_num = w
                except:
                    pass
        profile = get_profile_by_user(user=request.user)
        player_name, player_over_under_list = calc_weekly_points(year_num, request.user.username, overunder=True)
        compare_name, compare_over_under_list = calc_weekly_points(year_num, None, overunder=True)
        context = {
                'year_num': year_num,
                'week_num': week_num,
                'last_completed_week_num': last_completed_week_num,
                'last_inprogress_week_num': last_inprogress_week_num,
                'week_range': range(1, week_num + 1),
                'profile': profile,
                'player_name': player_name,
                'player_over_under_list': player_over_under_list,
                'player_color': '#009999',
                'compare_name': compare_name,
                'compare_over_under_list': compare_over_under_list,
                'compare_color': '#cc0099',
                'form': form,
                }

        return render(request,"pick10/index.html", context)
Exemplo n.º 10
0
def index():
    current_fx_config = get_current_fx_data()
    form = IndexForm()
    if form.validate_on_submit():
        flash("Changes applied")
        current_fx_config["enabled"] = form.enabled.data
        current_fx_config["brightness"] = float(form.brightness.data)
        current_fx_config["effect"] = form.effect.data
        set_current_fx_data(current_fx_config)
        return redirect(url_for("index"))
    else:
        form.enabled.data = current_fx_config["enabled"]
        form.brightness.data = current_fx_config["brightness"]
        form.effect.data = current_fx_config["effect"]
        return render_template("index.html", form=form)
Exemplo n.º 11
0
def create_index(request):
    account = request.user.get_profile().account
    if request.method == 'GET':
        index_qty = len(account.indexes.all())
        default_name = ''  #'Index_' + str(index_qty + 1)

        form = IndexForm(initial={'name': default_name})
        context = {
            'form': form,
            'account': request.user.get_profile().account,
            'navigation_pos': 'dashboard',
        }
        return render('new-index.html', request, context_dict=context)
    else:
        form = IndexForm(data=request.POST)
        if form.is_valid():
            try:
                client = ApiClient(account.get_private_apiurl())
                client.create_index(form.cleaned_data['name'])
                messages.success(request, 'New index created successfully.')
            except IndexAlreadyExists:
                context = {
                    'form': form,
                    'account': request.user.get_profile().account,
                    'navigation_pos': 'dashboard',
                }
                messages.error(request,
                               'You already have an Index with that name.')
                return render('new-index.html', request, context_dict=context)
            except TooManyIndexes:
                context = {
                    'form': form,
                    'account': request.user.get_profile().account,
                    'navigation_pos': 'dashboard',
                }
                messages.error(
                    request,
                    'You already have the maximum number of indexes allowed for your account. If you need more, please contact support.'
                )
                return render('new-index.html', request, context_dict=context)
            except Exception, e:
                print e
                messages.error(
                    request,
                    'Unexpected error creating the index. Try again in a few minutes'
                )
            return HttpResponseRedirect(reverse('dashboard'))
        else:
Exemplo n.º 12
0
def index(pagina):

    buscacidades = Cidades.query.order_by(Cidades.cidade).all()
    buscabanner = Banners.query.all()

    form = IndexForm()

    imoveis = funcbuscaimoveis()
    if request.method == 'POST':
        if form.cidade.data:
            imoveis = imoveis.filter(Imoveis.cidade == form.cidade.data)
        if form.bairro.data:
            imoveis = imoveis.filter(Imoveis.bairro == form.bairro.data)
        if form.tiponegocio.data:
            imoveis = imoveis.filter(
                Imoveis.tiponegocio == form.tiponegocio.data)
        if form.tipoimovel.data:
            imoveis = imoveis.filter(
                Imoveis.tipoimovel == form.tipoimovel.data)
        if form.valorminimo.data:
            imoveis = imoveis.filter(Imoveis.valor >= form.valorminimo.data)
        if form.valormaximo.data:
            imoveis = imoveis.filter(Imoveis.valor <= form.valormaximo.data)
        if form.nbanheiros.data:
            imoveis = imoveis.filter(
                Imoveis.nbanheiros == form.nbanheiros.data)
        if form.nbanheiros.data:
            imoveis = imoveis.filter(
                Imoveis.nbanheiros == form.nbanheiros.data)
        if form.nsuites.data:
            imoveis = imoveis.filter(Imoveis.nsuites == form.nsuites.data)
        if form.ngaragem.data:
            imoveis = imoveis.filter(Imoveis.ngaragem == form.ngaragem.data)
        if form.busca.data:
            imoveis = imoveis.filter(
                Imoveis.codigoimovel.ilike("%" + form.busca.data + "%"))

    novapagina = (pagina - 1) * 12
    contador = imoveis.count()
    imoveis = imoveis.limit(12).offset(novapagina).all()

    #logica da paginacao
    npaginas = 1
    while (contador >= 1):
        contador = contador - 12
        npaginas = npaginas + 1

    paginacao = []
    paginacao = range(1, npaginas)

    return render_template('index.html',
                           imoveis=imoveis,
                           form=form,
                           paginaatual=pagina,
                           npaginas=npaginas,
                           paginacao=paginacao,
                           buscacidades=buscacidades,
                           buscabanner=buscabanner)
Exemplo n.º 13
0
def create_index(request):
    account = request.user.get_profile().account
    if request.method == 'GET':
        index_qty = len(account.indexes.all())
        default_name = '' #'Index_' + str(index_qty + 1)
        
        form = IndexForm(initial={'name': default_name}) 
        context = {
          'form': form,
          'account': request.user.get_profile().account,
          'navigation_pos': 'dashboard',
        }
        return render('new-index.html', request, context_dict=context)
    else:
        form = IndexForm(data=request.POST)
        if form.is_valid():
            try:
                client = ApiClient(account.get_private_apiurl())
                client.create_index(form.cleaned_data['name'])
                messages.success(request, 'New index created successfully.')
            except IndexAlreadyExists:
                context = {
                  'form': form,
                  'account': request.user.get_profile().account,
                  'navigation_pos': 'dashboard',
                }
                messages.error(request, 'You already have an Index with that name.')
                return render('new-index.html', request, context_dict=context)
            except TooManyIndexes:
                context = {
                  'form': form,
                  'account': request.user.get_profile().account,
                  'navigation_pos': 'dashboard',
                }
                messages.error(request, 'You already have the maximum number of indexes allowed for your account. If you need more, please contact support.')
                return render('new-index.html', request, context_dict=context)
            except Exception, e:
                print e
                messages.error(request, 'Unexpected error creating the index. Try again in a few minutes')
            return HttpResponseRedirect(reverse('dashboard'))     
        else:
Exemplo n.º 14
0
def command():
    form = IndexForm()
    if form.validate_on_submit():
        data = {'from': DEVICE_NAME,'to': form.device_name.data, 'command': form.command.data}
        flash('New command for node {} add'.format(form.device_name.data))
        if os.path.exists('curr_commands.json'):
            if is_non_zero_file('curr_comands.json') == True:
                with open('curr_commands.json', 'r') as f:
                    js_data = json.load(f)
            with open('curr_commands.json', 'w') as f:
                if is_non_zero_file('curr_comands.json') == False:
                    index = 1
                    js_data = {}
                    js_data.update({index: data})
                    json.dump(js_data, f)
                else:
                    index = len(js_data) + 1
                    js_data.update({index: data})
                    json.dump(js_data, f)
        return redirect('/command')
    return render_template('/index.html', titles='', form=form)
Exemplo n.º 15
0
def index_view(request):
    session = request.session

    if request.method == 'POST':  # If the form has been submitted...
        form = IndexForm(request.POST)  # A form bound to the POST data
        if form.is_valid():
            c_d = form.cleaned_data
            if session.test_cookie_worked():
                session.delete_test_cookie()
                session['access_key_id'] = c_d.get('access_key_id')
                session['secret_access_key'] = c_d.get('secret_access_key')
                session['owner_id'] = c_d.get('owner_id')
                session['date_time'] = datetime.now()
                # Redirect after POST
                return HttpResponseRedirect(reverse('aws_clusters', args=[]))
            else:
                form.errors['non_field_errors'] = \
                    "Please enable cookies and try again"
    else:
        form = IndexForm()

    session.set_test_cookie()
    return render_to_response('aws_index.html', {
        'form': form,
    },
                              context_instance=RequestContext(request))
Exemplo n.º 16
0
def index():
    form2 = IndexForm()

    # if 'email' in session:
    #   return redirect(url_for('profile'))

    if request.method == 'POST':

        newindex = Index(form2.index1.data, form2.index2.data,
                         form2.index3.data, form2.index4.data)
        db.session.add(newindex)
        db.session.commit()
        print "see something?"
        return redirect(url_for('profile'))

    elif request.method == 'GET':
        return render_template('index.html', form=form2)
Exemplo n.º 17
0
def index():
    form = IndexForm(request.form)
    if request.method == "POST":
        if not os.path.exists(config.EVENTS_FILE):
            initEmptyDatabases()
        #create event
        #create new Database or une database
        new_event = DB_Events(name=form.name.data,
                              date=form.date.data,
                              offer=form.offer.data)
        db.session.add(new_event)
        db.session.commit()

        #TODO: Datenbank umbenennen, config anpassen, Datenbank testen

        return render_template('index.html', created=True, form=form)
    return render_template('index.html', form=form)
Exemplo n.º 18
0
def index():
    indexForm = IndexForm()
    if indexForm.save.data:
        if indexForm.rss.data:
            content = formContent.getDictionary(indexForm.email.data,
                                                indexForm.rss.data)
            mongo.insert(content)
            return redirect(url_for('index'))
    if indexForm.send.data:
        feeds = mongo.getFeedsForAddress(indexForm.email.data)
        try:
            _thread.start_new_thread(parseAndSendEmail,
                                     (feeds, indexForm.email.data))
            print("Started thread")
        except:
            print("Error starting thread")
        print()
        return redirect(url_for('index'))
    return render_template("index.html", title="Index", form=indexForm)
Exemplo n.º 19
0
def index():
	form = IndexForm()

	if form.publish.data:
		return redirect(url_for('publish'))

	if form.myimport.data:
		return redirect(url_for('importxml'))

#	if form.edit.data:
#		return redirect(url_for('edit'))	

	if form.query.data:
		return redirect(url_for('query'))

	if form.xml.data:
		return redirect(url_for('displayxml'))

	if form.rdf.data:
		return redirect(url_for('displayrdf'))
	return render_template('MAWSIndex.html', form=form)
Exemplo n.º 20
0
def index():
    form = IndexForm()
    return render_template('index.html', form=form)
Exemplo n.º 21
0
def index():
    form = IndexForm()
    if form.validate_on_submit():
        return redirect(url_for('search_results', query = g.search_form.search.data))
    return render_template('index.html', form=form)