예제 #1
0
파일: views.py 프로젝트: reinbach/cobuyer
def _show_cart(request, cart, form=None):
    """
    Display the contents of the cart selected
    """
    products = models.Item.objects.filter(cart=cart).order_by('description')
    
    paginator = DiggPaginator(products, MAX_RESULTS, **DIGG_ATTRS)

    try:
        page = int(request.GET.get('page', '1'))
    except ValueError:
        page = 1

    try: 
        products = paginator.page(page)
    except (EmptyPage, InvalidPage):
        products = paginator.page(paginator.num_pages)
        
    data = dict(
        cart=cart,
        products=products,
        curpage=page,
        form=form,
        tax_rate=settings.TAX_RATE,
        shipping_rate=settings.SHIPPING_RATE
    )
    return request_to_response(request, 'cart/index.html', data)
예제 #2
0
파일: forms.py 프로젝트: reinbach/cobuyer
 def save(self):
     data = self.cleaned_data
     
     user = User.objects.create_user(
         data['username'],
         data['email'],
         data['password']
     )
     
     user.first_name = data['first_name']
     user.last_name = data['last_name']
     user.save()
     
     profile = models.UserProfile.objects.create(
         user=user,
         number=data['number'],
     )
     
     subject = 'Confirm New Account'
     data = dict(
         user=user,
         data=data,
     )
     message = request_to_response(self.request, 'accounts/email/new_account.txt', data)
     send_mail(subject, message, settings.EMAIL_FROM, [user.email], fail_silently=True)
     
     return user
예제 #3
0
파일: views.py 프로젝트: reinbach/cobuyer
def home(request):
    profile = get_object_or_404(models.UserProfile, user=request.user)
    past_orders = cart.Cart.objects.filter(user=request.user, completed=True)
    data = dict(
        profile=profile,
        past_orders=past_orders,
    )
    return request_to_response(request, 'accounts/index.html', data)
예제 #4
0
파일: views.py 프로젝트: reinbach/cobuyer
def reset_password(request):
    if request.method == 'POST':
        form = forms.ResetPasswordForm(request, data=request.POST)
        if form.is_valid():
            user = form.save()
            form = forms.LoginForm(request)
            data = dict(
                messages=[u'A new Password has been sent to %s.' % user.email],
                form=form
            )
            return request_to_response(request, 'accounts/login.html', data)
    else:
        form = forms.ResetPasswordForm(request)
    data = dict(
        form=form
    )
    return request_to_response(request, 'accounts/reset_password.html', data)
예제 #5
0
파일: views.py 프로젝트: reinbach/cobuyer
def create(request):
    if request.method == 'POST':
        form = forms.AccountCreateForm(request, data=request.POST)
        if form.is_valid():
            user = form.save()
            form = forms.LoginForm(request)
            data = dict(
                messages=['A new account has been created.',],
                form=form
            )
            return request_to_response(request, 'accounts/login.html', data)
    else:
        form = forms.AccountCreateForm(request)
    data = dict(
        form=form,
    )
    return request_to_response(request, 'accounts/create.html', data)
예제 #6
0
파일: views.py 프로젝트: reinbach/cobuyer
def logout_user(request):
    logout(request)
    form = forms.LoginForm(request)
    data = dict(
        messages=[u'You have been logged out.',],
        form=form,
    )
    return request_to_response(request, 'accounts/login.html', data)
예제 #7
0
파일: views.py 프로젝트: reinbach/cobuyer
def _render(request, template, data):
    data['category_list'] = models.Category.objects.all()
    data['form_add'] = cart.AddProductForm(request, None)
    
    try:
        data['form']
    except KeyError:
        data['form'] = forms.ProductSearchForm(request)

    return request_to_response(request, template, data)
예제 #8
0
파일: views.py 프로젝트: reinbach/cobuyer
def login(request):
    if request.method == 'POST':
        form = forms.LoginForm(request, data=request.POST)
        if form.is_valid():
            return http.HttpResponseRedirect(reverse('account_home'))
    else:
        form = forms.LoginForm(request)
    data = dict(
        form=form,
    )
    return request_to_response(request, 'accounts/login.html', data)
예제 #9
0
파일: views.py 프로젝트: reinbach/cobuyer
def update(request):
    if request.method == 'POST':
        form = forms.AccountForm(request, data=request.POST)
        if form.is_valid():
            form.save()
            request.user.message_set.create(message=u'Account profile has been updated.')
            return http.HttpResponseRedirect(reverse('account_home'))
    else:
        form = forms.AccountForm(request)
    data = dict(
        form=form
    )
    return request_to_response(request, 'accounts/update.html', data)
예제 #10
0
파일: forms.py 프로젝트: reinbach/cobuyer
 def save(self):
     data = self.cleaned_data
     
     user = User.objects.get(email=data['email'])
     password = ''.join(Random().sample(string.letters+string.digits, 6))
     user.set_password(password)
     user.save()
     
     subject = 'Password Updated'
     data = dict(
         user=user,
         data=data,
         password=password,
     )
     message = request_to_response(self.request, 'accounts/email/new_password.txt', data)
     send_mail(subject, message, settings.EMAIL_FROM, [user.email], fail_silently=False)
     
     return user
예제 #11
0
파일: views.py 프로젝트: reinbach/cobuyer
def home(request):
    data = dict()
    return request_to_response(request, "index.html", data)
예제 #12
0
파일: views.py 프로젝트: reinbach/seahobo
def home(request):
    return request_to_response(request, "index.html", {})
예제 #13
0
파일: views.py 프로젝트: reinbach/cobuyer
def home(request):
    news_list = models.News.objects.all().order_by("-created")
    data = dict(news_list=news_list)
    return request_to_response(request, "news/index.html", data)
예제 #14
0
파일: views.py 프로젝트: reinbach/cobuyer
def view(request, slug):
    news_item = get_list_or_404(models.News.objects, slug=slug)
    data = dict(news_list=news_list)
    return request_to_response(request, "news/index.html", data)