Exemple #1
0
    def post(self, request):
        form = HomeForm(request.POST)
        if form.is_valid():
            text = form.cleaned_data['post']

        args = {'form': form, 'text': text}
        return render(request, self.template_name, args)
Exemple #2
0
def home():
    form = HomeForm()
    if not form.validate_on_submit():
        return render_template('home.html', form=form)
    type_of_routine = form.type_of_routine.data
    if request.method == "POST" and type_of_routine == 'Daily Routine':
        return redirect(url_for("daily_routine"))
    elif request.method == "POST" and type_of_routine == 'Weekly Routine':
        return redirect(url_for("weekly_routine"))
    else:
        return render_template("home.html")
Exemple #3
0
def page_edit_home(request):
    shop = request.shop
    static_pages = Page.objects.filter(shop=shop)
    dynamic_pages = DynamicPageContent.objects.filter(shop=shop)
    try:
        home = Home.objects.filter(shop=shop).get()
    except:
        home = Home(shop=shop)
        home.save()

    if request.POST:
        form = HomeForm(request.POST, request.FILES, instance=home)
        if form.is_valid():
            form.save()
            request.flash['message'] = unicode(_("Page successfully saved."))
            request.flash['severity'] = "success"
            return HttpResponseRedirect(reverse('page_edit_home'))
    else:
        form = HomeForm(instance=home)
    return render_to_response(
        'store_admin/web_store/pages_edit_home.html', {
            'form': form,
            'home': home,
            'static_pages': static_pages,
            'dynamic_pages': dynamic_pages
        }, RequestContext(request))
Exemple #4
0
def home():
    form = HomeForm()
    if form.validate_on_submit():
        if not current_user.is_authenticated:
            flash("Only registered users may enter new items to inventory. "
                  "Visitors are welcome to experiment with "
                  "pre-existing items on other pages. "
                  "Find item names in Dropdown box links.")
            return redirect(url_for('home'))
        bulk_cost = form.bulk_cost.data
        bulk_weight = form.bulk_weight.data
        food_cost = bulk_cost / (bulk_weight * 16)
        new_item = FoodItem(
            item_name=form.item_name.data,
            item_cost_oz=f"{food_cost:.2f}",
        )
        db.session.add(new_item)
        db.session.commit()
        results = f"{new_item.item_name} costs ${food_cost:.2f} per oz."
        return redirect(url_for('food_cost_per_oz', results=results))
    return render_template('index.html', form=form)
Exemple #5
0
def about(current_username = None):
	if current_user.is_authenticated :
		if User.query.filter_by(username = current_username).first():
			current_username = current_username = User.query.filter_by(username = current_username).first().username
		else :
			current_username = None
		print(current_username)
		Logout_Form = LogoutForm()
		Home_Form = HomeForm()
		Login_Form = LoginForm()
		return render_template('about.html',current_username = current_username,LogoutForm= Logout_Form,LoginForm = Login_Form,HomeForm = Home_Form)
	return redirect(url_for('login'))
def page_edit_home(request):
    shop = request.shop
    static_pages = Page.objects.filter(shop=shop)
    dynamic_pages = DynamicPageContent.objects.filter(shop=shop)
    try:
        home = Home.objects.filter(shop=shop).get()
    except:
        home = Home(shop=shop)
        home.save()

    if request.POST:
        form = HomeForm(request.POST, request.FILES, instance=home)
        if form.is_valid():
            form.save()
            request.flash['message'] = unicode(_("Page successfully saved."))
            request.flash['severity'] = "success"
            return HttpResponseRedirect(reverse('page_edit_home'))
    else:
        form = HomeForm(instance=home)
    return render_to_response('store_admin/web_store/pages_edit_home.html',
                              {'form': form, 'home': home, 'static_pages': static_pages, 'dynamic_pages': dynamic_pages},
                              RequestContext(request))
Exemple #7
0
def publications():
    #sessionId = request.cookies.get('hash')
    nick = session['profile']['name']
    form = HomeForm()
    #Przekazuje na sztywno haslo ktore jest akceptowane przez usluge, aby nie zmieniac zbyt mocno logiki modulu web
    response = requests.get('http://service:80/publications',
                            headers={"Authorization": nick + ":password"})

    print(response.text)
    response = json.loads(response.text)
    files = requests.get('http://service:80/files',
                         headers={"Authorization": nick + ":password"})
    files = json.loads(files.text)
    pubs = []
    fs = []
    for _, v in response.items():
        href = v["_links"]["view"]["href"]
        id = v["id"]
        pubs.append((id, href))

    for _, v in files.items():
        download = v["_links"]["download"]["href"]
        delete = v["_links"]["delete"]["href"]
        id = v["id"]
        name = v["name"]
        fs.append((id, name, download, delete))

    if form.validate_on_submit():
        files = {'file': form.uploadFile.data}
        r = requests.post('http://service/files',
                          files=files,
                          headers={"Authorization": nick + ":password"})
        return r.text

    return render_template('publications.html',
                           pubs=pubs,
                           form=form,
                           fs=fs,
                           user=nick)
Exemple #8
0
def home(request):
    if request.method == 'POST': # If the form has been submitted...
        form = HomeForm(request.POST) # A form bound to the POST data
        if form.is_valid(): # All validation rules pass
            # Process the data in form.cleaned_data
            # ...

            product = form.cleaned_data['product']
            branch_id = form.cleaned_data['branch'].branch_id
            testgroups = form.cleaned_data['testgroups']
            tg_ids = [str(x.testgroup_id) for x in testgroups]

            cursor = connection.cursor()
            cursor.execute(getsql(product.product_id, branch_id, tg_ids))

            # Create the HttpResponse object with the appropriate CSV header.
            response = HttpResponse(mimetype='text/csv')
            response['Content-Disposition'] = 'attachment; filename=%s_litmusoutput.csv' % product.name

            csv_writer = UnicodeWriter(response)
            csv_writer.writerow([i[0] for i in cursor.description]) # write headers
            csv_writer.writerows(cursor)
            del csv_writer # this will close the CSV file

            return response
    else:
        form = HomeForm() # An unbound form

    branches = Branches.objects.all().order_by('name')
    testgroups = Testgroups.objects.all().order_by('name')

    return render_to_response('home.html',
                              {'form': form,
                               'branches': branches,
                               'testgroups': testgroups
                               },
                              context_instance=RequestContext(request))
Exemple #9
0
def page_edit_home(request):
    shop = request.shop
    static_pages = Page.objects.filter(shop=shop)
    dynamic_pages = DynamicPageContent.objects.filter(shop=shop)
    try:
        home = Home.objects.filter(shop=shop).get()
    except:
        home = Home(shop=shop)
        home.save()

    if request.POST:
        form = HomeForm(request.POST, request.FILES, instance=home)
        if form.is_valid():
            form.save()
            request.flash["message"] = unicode(_("Page successfully saved."))
            request.flash["severity"] = "success"
            return HttpResponseRedirect(reverse("page_edit_home"))
    else:
        form = HomeForm(instance=home)
    return render_to_response(
        "store_admin/web_store/pages_edit_home.html",
        {"form": form, "home": home, "static_pages": static_pages, "dynamic_pages": dynamic_pages},
        RequestContext(request),
    )
Exemple #10
0
def home(request):
    if request.method == 'POST': # If the form has been submitted...
        form = HomeForm(request.POST) # A form bound to the POST data
        if form.is_valid(): # All validation rules pass

            # Process the data in form.cleaned_data
            # ...

            product = form.cleaned_data['product']
            branch = form.cleaned_data['branch']
            testgroups = form.cleaned_data['testgroups']

            response_data = get_response_json(product, branch, testgroups)



            # Create the HttpResponse object with the appropriate CSV header.
            response = HttpResponse(dumps(response_data), mimetype='application/json')
            response['Content-Disposition'] = 'attachment; filename=%s_litmusoutput.json' % product.name
            logger.error(response)

            return response
    else:
        logger.error('logging the request')
        logger.error(request)
        form = HomeForm() # An unbound form

    branches = Branch.objects.all().order_by('name')
    testgroups = Testgroup.objects.all().order_by('name')

    return render_to_response('home.html',
                              {'form': form,
                               'branches': branches,
                               'testgroups': testgroups
                               },
                              context_instance=RequestContext(request))
Exemple #11
0
    def post(self, request):
        form = HomeForm(request.POST)
        if form.is_valid():
            post = form.save(commit=False)
            post.user = request.user
            post.save()
            text = form.cleaned_data['post']
            form = HomeForm()

        args = {'form': form, 'text': text}
        return render(request, self.template_name, args)
Exemple #12
0
def create(request):
    if request.method == 'POST':
        form = HomeForm(request.POST)
        if form.is_valid():
            home = form.save(commit=False)
            home.home_data = timezone.now()
            home.save()
            return redirect('apps.hello.views.home', pk=home.pk)
    else:
        form = HomeForm()
        args = {}
        args['form'] = form
    return render(request, 'post_edit.html', args)
Exemple #13
0
def post_edit(request, pk):
    home = get_object_or_404(Home, pk=pk)
    args = {}
    args['home'] = home
    if request.method == 'POST':
        form = HomeForm(request.POST, instance=home)
        if form.is_valid():
            home = form.save(commit=False)
            home.home_data = timezone.now()
            home.save()
            return redirect('apps.hello.views.home', pk=home.pk)
    else:
        form = HomeForm(instance=home)
        args['form'] = form
    return render(request, 'post_edit.html', args)
Exemple #14
0
    def get(self, request):
        form = HomeForm()
        posts = Post.objects.all().order_by('-created')

        args = {'form': form, 'posts': posts}
        return render(request, self.template_name, args)
Exemple #15
0
 def get(self, request):
     form = HomeForm()
     return render(request, self.template_name, {'form': form})