コード例 #1
0
ファイル: views.py プロジェクト: ContactEngineering/TopoBank
    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)

        active_terms = TermsAndConditions.get_active_terms_list()

        if not self.request.user.is_anonymous:
            context['agreed_terms'] = TermsAndConditions.objects.filter(
                userterms__date_accepted__isnull=False,
                userterms__user=self.request.user).order_by('date_created')

            context['not_agreed_terms'] = active_terms.filter(
                Q(userterms=None) | \
                (Q(userterms__date_accepted__isnull=True) & Q(userterms__user=self.request.user)))\
                .order_by('date_created')
        else:
            context['active_terms'] = active_terms.order_by('date_created')

        context['extra_tabs'] = [{
            'login_required': False,
            'icon': 'file-contract',
            'title': "Terms and Conditions",
            'active': True,
        }]
        context['connect_fixed_tabs_with_extra_tabs'] = False

        return context
コード例 #2
0
ファイル: context_processors.py プロジェクト: sdc50/tethys
def tethys_global_settings_context(request):
    """
    Add the current Tethys app metadata to the template context.
    """
    from .models import Setting
    from termsandconditions.models import TermsAndConditions

    # Get settings
    site_globals = Setting.as_dict()

    # Get terms and conditions

    # Grrr!!! TermsAndConditions has a different interface for Python 2 and 3
    try:
        # for Python 3
        site_globals.update(
            {'documents': TermsAndConditions.get_active_terms_list()})
    except AttributeError:
        # for Python 3
        site_globals.update(
            {'documents': TermsAndConditions.get_active_list(as_dict=False)})

    context = {'site_globals': site_globals}

    return context
コード例 #3
0
 def handle(self, *args, **options):
     active_terms = TermsAndConditions.get_active_terms_list()
     for term in active_terms:
         old_accepts = UserTermsAndConditions.objects.filter(
             terms__slug=term.slug).exclude(terms__pk=term.pk)
         logger.debug(
             f"About to delete these old terms accepts: {old_accepts}")
         old_accepts.delete()
コード例 #4
0
    def __init__(self, *args, **kwargs):
        kwargs.pop('instance', None)

        terms_list = kwargs.get('initial', {}).get('terms', None)

        if terms_list is None:  # pragma: nocover
            terms_list = TermsAndConditions.get_active_terms_list()

        self.terms = forms.ModelMultipleChoiceField(
            terms_list, widget=forms.MultipleHiddenInput)

        super(UserTermsAndConditionsModelForm, self).__init__(*args, **kwargs)
コード例 #5
0
    def __init__(self, *args, **kwargs):
        kwargs.pop("instance", None)

        terms_list = kwargs.get("initial", {}).get("terms", None)

        if terms_list is None:  # pragma: nocover
            terms_list = TermsAndConditions.get_active_terms_list()

        if terms_list is QuerySet:
            self.terms = forms.ModelMultipleChoiceField(
                terms_list, widget=forms.MultipleHiddenInput)
        else:
            self.terms = terms_list

        super().__init__(*args, **kwargs)
コード例 #6
0
def tethys_global_settings_context(request):
    """
    Add the current Tethys app metadata to the template context.
    """
    from .models import Setting
    from termsandconditions.models import TermsAndConditions

    # Get settings
    site_globals = Setting.as_dict()

    # Get terms and conditions
    site_globals.update({'documents': TermsAndConditions.get_active_terms_list()})

    context = {'site_globals': site_globals}

    return context
コード例 #7
0
    def __init__(self, *args, **kwargs):
        kwargs.pop('instance', None)

        terms_list = kwargs.get('initial', {}).get('terms', None)

        if terms_list is None:  # pragma: nocover
            terms_list = TermsAndConditions.get_active_terms_list()

        if terms_list is QuerySet:
            self.terms = forms.ModelMultipleChoiceField(
                terms_list,
                widget=forms.MultipleHiddenInput
            )
        else:
            self.terms = terms_list

        super(UserTermsAndConditionsModelForm, self).__init__(*args, **kwargs)
コード例 #8
0
def tethys_global_settings_context(request):
    """
    Add the current Tethys app metadata to the template context.
    """
    from .models import Setting
    from termsandconditions.models import TermsAndConditions

    # Get settings
    site_globals = Setting.as_dict()

    # Get terms and conditions
    site_globals.update(
        {'documents': TermsAndConditions.get_active_terms_list()})

    context = {'site_globals': site_globals}

    return context