Esempio n. 1
0
def overview(request):
    from blog_pages.models import Post
    from shops.models import Shop
    from market_community.models import MarketPlaceAnnouncement
    from market.forms import MarketMailingListMemberForm

    marketplace = request.marketplace
    announcements = MarketPlaceAnnouncement.objects.filter(
        marketplace=marketplace).order_by("-posted_on")[:5]
    shops = Shop.actives.filter(
        marketplace=marketplace).order_by("-date_time")[:3]
    last_posts = Post.objects.filter(shop__marketplace=marketplace).filter(
        draft=False).order_by("-date_time")[:5]

    if request.method == "POST":
        form = MarketMailingListMemberForm(request.POST)
        if form.is_valid():
            member = form.save(commit=False)
            member.marketplace = request.marketplace
            member.save()
            request.flash['message'] = unicode(
                _("Email successfully registered."))
            request.flash['severity'] = "success"
            return HttpResponseRedirect(reverse("market_community"))
    else:
        form = MarketMailingListMemberForm()

    return render_to_response(
        "%s/community/overview.html" % request.marketplace.template_prefix, {
            'announcements': announcements,
            'last_posts': last_posts,
            'shops': shops,
            'mailing_list_form': form,
        }, RequestContext(request))
Esempio n. 2
0
def home(request):
    from shops.models import Shop
    from inventory.models import Product
    from market_buy.models import MarketPlacePick, DealerPick
    from market.forms import MarketMailingListMemberForm

    marketplace = request.marketplace
    market_place_picks = MarketPlacePick.get_available_picks(marketplace)
    featured_dealers = DealerPick.objects.filter(
        marketplace=marketplace).order_by("order")[:2]
    recently_products = Product.objects.filter(
        shop__marketplace=marketplace,
        has_image=True).order_by("-date_time")[:20]

    if request.method == "POST":
        form = MarketMailingListMemberForm(request.POST)
        if form.is_valid():
            member = form.save(commit=False)
            member.marketplace = request.marketplace
            member.save()
            request.flash['message'] = unicode(
                _("Email successfully registered."))
            request.flash['severity'] = "success"
            return HttpResponseRedirect(reverse("market_home"))
    else:
        form = MarketMailingListMemberForm()

    return render_to_response(
        "%s/home.html" % request.marketplace.template_prefix, {
            'market_place_picks': market_place_picks,
            'featured_dealers': featured_dealers,
            'recently_products': recently_products,
            'newsletter_form': form
        }, RequestContext(request))
def home(request):
    from shops.models import Shop
    from inventory.models import Product
    from market_buy.models import MarketPlacePick, DealerPick
    from market.forms import MarketMailingListMemberForm
    
    marketplace = request.marketplace
    market_place_picks = MarketPlacePick.objects.filter(marketplace=marketplace).order_by("order")
    featured_dealers = DealerPick.objects.filter(marketplace=marketplace).order_by("order")[:2]
    recently_products = Product.objects.filter(shop__marketplace=marketplace, has_image=True).order_by("-date_time")[:20]
    
    if request.method == "POST":
        form = MarketMailingListMemberForm(request.POST)
        if form.is_valid():
            member = form.save(commit=False)
            member.marketplace = request.marketplace
            member.save()
            request.flash['message'] = unicode(_("Email successfully registered."))
            request.flash['severity'] = "success"
            return HttpResponseRedirect(reverse("market_home"))
    else:
        form = MarketMailingListMemberForm()
        
    return render_to_response("%s/home.html" % request.marketplace.template_prefix, 
                              {
                               'market_place_picks' : market_place_picks,
                               'featured_dealers' : featured_dealers,
                               'recently_products' : recently_products,
                               'newsletter_form': form
                               }, 
                              RequestContext(request))
def overview(request):
    from blog_pages.models import Post
    from shops.models import Shop
    from market_community.models import MarketPlaceAnnouncement
    from market.forms import MarketMailingListMemberForm
    
    marketplace = request.marketplace
    announcements = MarketPlaceAnnouncement.objects.filter(marketplace=marketplace).order_by("-posted_on")[:5]
    shops = Shop.objects.filter(marketplace=marketplace).order_by("-date_time")[:3]
    last_posts = Post.objects.filter(shop__marketplace=marketplace).order_by("-date_time")[:5]


    if request.method == "POST":
        form = MarketMailingListMemberForm(request.POST)
        if form.is_valid():
            member = form.save(commit=False)
            member.marketplace = request.marketplace
            member.save()
            request.flash['message'] = unicode(_("Email successfully registered."))
            request.flash['severity'] = "success"
            return HttpResponseRedirect(reverse("market_community"))
    else:
        form = MailingListMemberForm()   
    
    return render_to_response("%s/community/overview.html" % request.marketplace.template_prefix, 
                              {
                               'announcements' : announcements,
                               'last_posts' : last_posts,
                               'shops' : shops,
                               'mailing_list_form' : form,
                              },
                              RequestContext(request))