예제 #1
0
파일: views.py 프로젝트: hnejadi/xerobis
    return wish, msg


def _wishlist_remove(request):
    success = False
    msg = ""
    wish, msg = _wish_from_post(request)
    if wish:
        success = True
        wish.delete()

    return success, msg


def _remove_wishes_on_order(order=None, **kwargs):
    log.debug("Caught order success, inspecting for wishes to remove.")
    if order:
        products = [item.product for item in order.orderitem_set.all()]
        for wish in ProductWish.objects.filter(contact=order.contact, product__in=products):
            log.debug("removing fulfilled wish for: %s", wish)
            wish.delete()


order_success.connect(_remove_wishes_on_order, sender=Order)


def _wishlist_requires_login(request):
    log.debug("wishlist requires login")
    ctx = RequestContext(request, {"login_url": settings.LOGIN_URL})
    return render_to_response("wishlist/login_required.html", ctx)
예제 #2
0

def _wishlist_remove(request):
    success = False
    msg = ""
    wish, msg = _wish_from_post(request)
    if wish:
        success = True
        wish.delete()

    return success, msg


def _remove_wishes_on_order(order=None, **kwargs):
    log.debug("Caught order success, inspecting for wishes to remove.")
    if order:
        products = [item.product for item in order.orderitem_set.all()]
        for wish in ProductWish.objects.filter(contact=order.contact,
                                               product__in=products):
            log.debug('removing fulfilled wish for: %s', wish)
            wish.delete()


order_success.connect(_remove_wishes_on_order, sender=Order)


def _wishlist_requires_login(request):
    log.debug("wishlist requires login")
    return render(request, 'wishlist/login_required.html',
                  {'login_url': settings.LOGIN_URL})
예제 #3
0
파일: models.py 프로젝트: tatenen/store
from django.db import models
from django.utils.translation import ugettext_lazy as _
# from satchmo_utils.thumbnail.field import ImageWithThumbnailField

from store.localsite.listeners import process_registration, order_after_success_create
from satchmo_store.accounts.signals import satchmo_registration_verified
from satchmo_store.shop.signals import order_success


class News(models.Model):
    title = models.CharField(verbose_name=_(u"Заголовок"), max_length=150)
    """
    image = ImageWithThumbnailField(
        verbose_name=_('Picture'),
        upload_to="__DYNAMIC__",
        # name_field="_filename",
        max_length=200)
        """
    image = models.ImageField(verbose_name=_('Picture'), upload_to='images/news')
    body = models.TextField(verbose_name=_(u'Новость'),)
    ctime = models.DateTimeField(verbose_name=_('Date added'), auto_now=False, auto_now_add=True)
    enabled = models.BooleanField(verbose_name=_(u'Показывать?'), default=True)

    def __unicode__(self):
        return self.title


satchmo_registration_verified.connect(process_registration, sender=None)
order_success.connect(order_after_success_create, sender=None)
예제 #4
0


_contain_inline = ModelMapper.access_inline

_objmap_models = [
    ModelMapper.get_model(model_name) for model_name in ModelMapper.mapping.keys() \
    if model_name not in _contain_inline
    ]

_objmap_models_inline = [
    ModelMapper.get_model(model_name) for model_name in _contain_inline
    ]


# Signal registration
def _reg_signal(signal, method):
    '''Return method for registering signals.'''
    def _method(model):
        signal.connect(method, sender=model)
    return _method



map(_reg_signal(pre_delete, on_delete_obj_mapper), _objmap_models+_objmap_models_inline)
map(_reg_signal(post_save, on_save_obj_mapper), _objmap_models)
map(_reg_signal(post_save_all, on_save_obj_mapper), _objmap_models_inline)

#special order_success action
order_success.connect(on_order_success_mapper)
예제 #5
0
from satchmo_store.shop.signals import order_success, order_cancelled, satchmo_order_status_changed
from satchmo_store.accounts.signals import satchmo_registration
from satchmo_store.shop.models import Order
from satchmo_store.accounts.forms import RegistrationForm
from satchmo_store import shop
from signals_ahoy.signals import collect_urls

from reward.listeners import *
from reward.urls import add_reward_urls

log = logging.getLogger('rewards.listeners')

log.debug("Adding reward listeners")

satchmo_registration.connect(create_reward_listener, sender=None)
satchmo_order_status_changed.connect(rcv_order_status_changed, sender=None)
#order_cancelled.connect(remove_points, sender=None)
order_success.connect(add_points_on_order, sender=None)


collect_urls.connect(add_reward_urls, sender=shop)
예제 #6
0
from satchmo_store.shop.signals import order_success, order_cancelled, satchmo_order_status_changed
from satchmo_store.accounts.signals import satchmo_registration
from satchmo_store.shop.models import Order
from satchmo_store.accounts.forms import RegistrationForm
from satchmo_store import shop
from signals_ahoy.signals import collect_urls

from reward.listeners import *
from reward.urls import add_reward_urls

log = logging.getLogger('rewards.listeners')

log.debug("Adding reward listeners")

satchmo_registration.connect(create_reward_listener, sender=None)
satchmo_order_status_changed.connect(rcv_order_status_changed, sender=None)
#order_cancelled.connect(remove_points, sender=None)
order_success.connect(add_points_on_order, sender=None)

collect_urls.connect(add_reward_urls, sender=shop)
예제 #7
0
from django.db import models
from django.utils.translation import ugettext as _

from satchmo_store.shop.models import Cart, Order, OrderPayment
from django.contrib.auth.models import User

from satchmo_store.shop.signals import order_success
from listeners import order_billed

import config
PAYMENT_PROCESSOR = True

class StripeToken(models.Model):
    orderpayment = models.ForeignKey(OrderPayment, unique=True, related_name="stripe_tokens")
    payment_token = models.CharField(_("Payment Token"), max_length=128, blank=True, null=True, editable=False)
    display_cc = models.CharField(_("CC Number (Last 4 digits)"), max_length=4,)
    use_saved_card = models.BooleanField()
    save_this_card = models.BooleanField()

class StripeCustomer(models.Model):
   # User must be registered with the store
   user = models.ForeignKey(User, unique=True)
   # This ID is supplied by Stripe on user creation
   stripe_id = models.CharField(_("Stripe ID"), max_length=50, )

#User.stripe = property(lambda u: StripeCustomer.objects.get_or_create(user=u)[0])

order_success.connect(order_billed, sender=None)
예제 #8
0
    send_mail_args['subject'] = send_mail_args['subject'] + ' - %s' % orderid


def modify_mail_context(sender, send_mail_args=None, context=None, **kwargs):
    """
    Modify mail context by adding the shop config as a template variable.
    """
    if send_mail_args is None:
        send_mail_args = {}
    if context is None:
        context = {}
    if 'shop' in context:
        return

    from satchmo_store.shop.models import Config
    shop_config = Config.objects.get_current()
    site_domain = Site.objects.get_current().domain

    context['shop'] = shop_config
    context['site_domain'] = site_domain


# Connect listeners to signals.
sending_store_mail.connect(modify_subject)
rendering_store_mail.connect(modify_mail_context)
form_init.connect(form_terms_listener, sender=PaymentContactInfoForm)
form_init.connect(newsletter_form_listener_init, sender=PaymentContactInfoForm)
form_init.connect(pay_ship_form_init, sender=SimplePayShipForm)
form_postsave.connect(newsletter_form_listener, sender=PaymentContactInfoForm)
order_success.connect(contact_reset_listener)