예제 #1
0
def upload(request):
    if request.user.is_authenticated():
        if request.method == 'POST':
            form = AddMaterialForm(request.POST, request.FILES)
            if form.is_valid():
                material = Material(doc=request.FILES['doc'])
                material = form.save()
                material.uploader = request.user.profile
                material.save()
                search_engine = build_search_engine()
                return redirect("/my_materials/")
        else:
            form = AddMaterialForm()
        c = {'form': form}
        return render(request, 'upload.html', c)
    else:
        return redirect("/login/")
def add_product(request):
    if request.user.is_authenticated():
        if request.method == 'POST':
            form = AddProductForm(request.POST, request.FILES)
            if form.is_valid():
                product = Product(picture=request.FILES['picture'])
                product = form.save()
                product.owner = request.user.profile
                product.save()
                search_engine = build_search_engine()
                return redirect("/my_products/")
        else:
            form = AddProductForm()
        c = {'form': form}
        return render(request, 'add_product.html', c)
    else:
        return redirect("/login/")
예제 #3
0
def upload(request):
    if request.user.is_authenticated():
        if request.method == 'POST':
            form = AddMaterialForm(request.POST, request.FILES)
            if form.is_valid():
                material = Material(doc = request.FILES['doc'])
                material = form.save()
                material.uploader=request.user.profile
                material.save()
                search_engine = build_search_engine()
                return redirect("/my_materials/")
        else:
            form = AddMaterialForm()
        c = {
            'form': form
        }
        return render(request, 'upload.html', c)
    else:
        return redirect("/login/")
def add_product(request):
    if request.user.is_authenticated():
        if request.method == 'POST':
            form = AddProductForm(request.POST, request.FILES)
            if form.is_valid():
                product = Product(picture = request.FILES['picture'])
                product = form.save()
                product.owner=request.user.profile
                product.save()
                search_engine = build_search_engine()
                return redirect("/my_products/")
        else:
            form = AddProductForm()
        c = {
            'form': form
        }
        return render(request, 'add_product.html', c)
    else:
        return redirect("/login/")
예제 #5
0
from django.http import HttpResponseRedirect, HttpResponse, Http404
from django import forms
from PIL import Image as PImage
from os.path import join as pjoin
from datetime import datetime, timedelta
from nltk import word_tokenize
import pylab as plt
from django.shortcuts import get_object_or_404
from filetransfers.api import serve_file

from forms import *
from models import *
from util import *
from search import build_search_engine

search_engine = build_search_engine()


# Main Page
def home(request):
    if request.method == 'POST' and request.POST.get('search'):
        form = SearchForm(request.POST)
        if form.is_valid():  
            search = form.save(commit = False)
            if request.user.is_authenticated():
                search.user = request.user.profile # if the user is logged in
            search.save()  
            return redirect("/search/"+str(search.id))
    else:
        form = SearchForm()  
    c = {
예제 #6
0
from django.http import HttpResponseRedirect, HttpResponse, Http404
from django import forms
from PIL import Image as PImage
from os.path import join as pjoin
from datetime import datetime, timedelta
from nltk import word_tokenize
import pylab as plt
from django.shortcuts import get_object_or_404
from filetransfers.api import serve_file

from forms import *
from models import *
from util import *
from search import build_search_engine

search_engine = build_search_engine()


# Main Page
def home(request):
    if request.method == 'POST' and request.POST.get('search'):
        form = SearchForm(request.POST)
        if form.is_valid():
            search = form.save(commit=False)
            if request.user.is_authenticated():
                search.user = request.user.profile  # if the user is logged in
            search.save()
            return redirect("/search/" + str(search.id))
    else:
        form = SearchForm()
    c = {'form': form}