コード例 #1
0
def initialize_page(**kwargs):
    """
    :rtype: shuup.simple_cms.models.Page
    """
    kwargs.setdefault("_current_language", "en")
    kwargs.setdefault("title", "test")
    kwargs.setdefault("url", str(uuid.uuid4()))
    kwargs.setdefault("content", CONTENT)
    if kwargs.pop("eternal", False):
        kwargs.setdefault("available_from", datetime.datetime(1900, 1, 1))
        kwargs.setdefault("available_to", datetime.datetime(2900, 1, 1))
    page = Page(**kwargs)
    page.full_clean()
    return page
コード例 #2
0
ファイル: utils.py プロジェクト: suutari/shoop
def initialize_page(**kwargs):
    """
    :rtype: shuup.simple_cms.models.Page
    """
    kwargs.setdefault("_current_language", "en")
    kwargs.setdefault("title", "test")
    kwargs.setdefault("url", str(uuid.uuid4()))
    kwargs.setdefault("content", CONTENT)
    if kwargs.pop("eternal", False):
        kwargs.setdefault("available_from", datetime.datetime(1900, 1, 1))
        kwargs.setdefault("available_to", datetime.datetime(2900, 1, 1))
    page = Page(**kwargs)
    page.full_clean()
    return page
コード例 #3
0
    def ensure_for_user(cls, user, shop, consent_documents):
        documents = []
        for page in consent_documents:
            Page.create_initial_revision(page)
            version = Version.objects.get_for_object(page).first()
            consent_document = GDPRUserConsentDocument.objects.create(page=page, version=version)
            documents.append(consent_document)

        # ensure only one consent exists for this user in this shop
        consent = cls.objects.filter(shop=shop, user=user).first()
        if consent:
            consents = cls.objects.filter(shop=shop, user=user).order_by("-created_on")
            if consents.count() > 1:
                # There are multiple consents, remove excess
                ids = [c.id for c in consents.all() if c.id != consent.id]
                cls.objects.filter(pk__in=ids).delete()
        else:
            consent = cls.objects.create(shop=shop, user=user)

        consent.documents.set(documents)
        return consent
コード例 #4
0
ファイル: models.py プロジェクト: ruqaiya/shuup
    def ensure_for_user(cls, user, shop, consent_documents):
        documents = []
        for page in consent_documents:
            Page.create_initial_revision(page)
            version = Version.objects.get_for_object(page).first()
            consent_document = GDPRUserConsentDocument.objects.create(
                page=page,
                version=version
            )
            documents.append(consent_document)

        # ensure only one consent exists for this user in this shop
        consent = cls.objects.filter(shop=shop, user=user).first()
        if consent:
            consents = cls.objects.filter(shop=shop, user=user).order_by("-created_on")
            if consents.count() > 1:
                # There are multiple consents, remove excess
                ids = [c.id for c in consents.all() if c.id != consent.id]
                cls.objects.filter(pk__in=ids).delete()
        else:
            consent = cls.objects.create(shop=shop, user=user)

        consent.documents = documents
        return consent