コード例 #1
0
 def get_context_data(self, **kwargs):
     context = super(BaseAccessListLab, self).get_context_data(
         **kwargs)
     context.update(FormView.get_context_data(self, **kwargs))
     context['role'] = self.role
     context['user_create_form'] = self.user_create_form()
     return context
コード例 #2
0
    def get_context_data(self, **kwargs):
        """ Get Win data for use in the template """

        context = FormView.get_context_data(self, **kwargs)
        context.update({"win": self.win_dict})
        context['win']['date'] = date_parser(self.win_dict['date'])
        return context
コード例 #3
0
ファイル: views.py プロジェクト: adamchainz/export-wins-ui
    def get_context_data(self, **kwargs):
        """ Get Win data for use in the template """

        context = FormView.get_context_data(self, **kwargs)
        context.update({"win": self.win_dict})
        context['win']['date'] = date_parser(self.win_dict['date'])
        return context
コード例 #4
0
ファイル: access.py プロジェクト: solvo/organilab
 def get_context_data(self, **kwargs):
     context = super(BaseAccessListLab, self).get_context_data(
         **kwargs)
     context.update(FormView.get_context_data(self, **kwargs))
     context['role'] = self.role
     context['user_create_form'] = self.user_create_form()
     return context
コード例 #5
0
ファイル: views.py プロジェクト: harupapa-git001/Python_Flask
 def get_context_data(self, **kwargs):
     # Needed since Django 1.9 because get_context_data is no longer called
     # with the form instance
     if "form" not in kwargs:
         kwargs["form"] = self.get_form()
     kwargs = ArticleMixin.get_context_data(self, **kwargs)
     kwargs.update(FormView.get_context_data(self, **kwargs))
     return kwargs
コード例 #6
0
ファイル: single_page.py プロジェクト: sidaga/shoop
 def get_context_data(self, **kwargs):
     ctx = FormView.get_context_data(self, **kwargs)
     basket = self.request.basket  # type: shoop.front.basket.objects.BaseBasket
     ctx["basket"] = basket
     errors = list(basket.get_validation_errors(shop=self.request.shop))
     ctx["errors"] = errors
     ctx["orderable"] = (not errors)
     return ctx
コード例 #7
0
ファイル: single_page.py プロジェクト: noyonthe1/shoop
 def get_context_data(self, **kwargs):
     ctx = FormView.get_context_data(self, **kwargs)
     basket = self.request.basket  # type: shoop.front.basket.objects.BaseBasket
     ctx["basket"] = basket
     errors = list(basket.get_validation_errors(shop=self.request.shop))
     ctx["errors"] = errors
     ctx["orderable"] = (not errors)
     return ctx
コード例 #8
0
ファイル: single_page.py プロジェクト: cuberskulk/shoop
 def get_context_data(self, **kwargs):
     ctx = FormView.get_context_data(self, **kwargs)
     basket = self.request.basket  # type: shoop.front.basket.objects.BaseBasket
     ctx["basket"] = basket
     basket.calculate_taxes()
     errors = list(basket.get_validation_errors())
     ctx["errors"] = errors
     ctx["orderable"] = not errors
     return ctx
コード例 #9
0
ファイル: views.py プロジェクト: atiberghien/formatools
    def get_context_data(self, **kwargs):
        context = FormView.get_context_data(self, **kwargs)

        form = context["form"]
        headers = []
        context["page_label"] = form.cleaned_data["page_label"]
        context["contents"] = []
        if form.is_valid():
            f = io.StringIO(
                form.cleaned_data["csv_file"].read().decode('utf-8'))
            csv_reader = csv.reader(f, delimiter=',')
            headers = next(csv_reader)
            for row in csv_reader:
                content = OrderedDict({})
                for i, header in enumerate(headers):
                    content[header] = row[i]
                context["contents"].append(content)
        return context
コード例 #10
0
ファイル: views.py プロジェクト: pixmin/poimap
    def get_context_data(self, **kwargs):
        context = FormView.get_context_data(self, **kwargs)
        context["travels"] = self.request.session["travels"]
        total = 0
        for travel in context["travels"]:
            total += float(travel["go"]["travel_price"])
            if "return" in travel and travel["return"]:
                total += float(travel["return"]["travel_price"])
        context["total"] = total

        if self.order_num:
            try:
                order = Order.objects.get(num=self.order_num)
                payplug.set_secret_key(settings.PAYPLUG_KEY)
                cancel_url = self.request.build_absolute_uri(
                    reverse('transportation-checkout'))
                return_url = self.request.build_absolute_uri(
                    reverse('transportation-checkout-confirmation',
                            args=(order.num, )))
                payment_data = {
                    'amount': int(total * 100),
                    'currency': 'EUR',
                    'customer': {
                        'first_name': order.customer.first_name,
                        'last_name': order.customer.last_name,
                        'email': order.customer.email
                    },
                    'hosted_payment': {
                        'return_url': return_url,
                        'cancel_url': cancel_url,
                    },
                    'metadata': {
                        'order_num': order.num,
                        'customer_id': order.customer.id,
                    },
                }
                payment = payplug.Payment.create(**payment_data)
                context["payment"] = payment
                context["order"] = order
            except Order.DoesNotExist:
                pass

        return context
コード例 #11
0
ファイル: views.py プロジェクト: atiberghien/formatools
    def get_context_data(self, **kwargs):
        context = FormView.get_context_data(self, **kwargs)

        form = context["form"]
        context["headers"] = ("username", "level", "xp", "courses",
                              "certificates")  #, "achievements")
        context["rows"] = []
        for url in form.cleaned_data["account_list"].split('\n'):
            resp = requests.get(url.strip())
            html_soup = BeautifulSoup(resp.text, 'html.parser')
            try:
                username = list(
                    html_soup.select_one(
                        "div.userProfile .details .name").stripped_strings)[0]
                level = list(
                    html_soup.select_one("div.userProfile .details .detail div"
                                         ).stripped_strings)[1]
                xp = html_soup.select_one(
                    "div.userProfile .details .detail div:nth-child(2) span"
                ).text.replace(" XP", "")
                courses = ", ".join([
                    "%s (%s)" % (course.select_one('a')["title"].split(' ')[0],
                                 course.select_one('.courseXp').string)
                    for course in html_soup.select(
                        "div.userCourses .courseWrapper")
                ])
                certificates = ", ".join([
                    "%s (%s)" % (certif["title"], " ".join(
                        list(
                            certif.select_one(
                                ".details .date").stripped_strings))) for
                    certif in html_soup.select("#certificates .certificate")
                ])
                # achievements = ", ".join(["%s (%s)" % (achiev["title"], " ".join(list(achiev.select_one(".description").stripped_strings))) for achiev in html_soup.select(".userAchievements.full .achievement:not(.disabled)")])
                context["rows"].append((username, level, xp, courses,
                                        certificates))  #, achievements))
            except:
                print("ERROR", url.strip())
            # break
        return context
コード例 #12
0
ファイル: views.py プロジェクト: drayanaindra/polling
 def get_context_data(self, **kwargs):
     """ pass args form get to template as context 
     
     the add_choices context is to give how many additional input choices
     to the form
     
     """
     context = FormView.get_context_data(self, **kwargs)
     
     # checking from POST request
     request_choice = self.request.POST.get('request_choice',0)
     last_choice = int (request_choice) - 2 if request_choice else 0
     
     # assign from last_choice, ignore from GET, because input from POST
     # from javascript has higher precedence than GET
     if last_choice :
         context['add_choices'] =  last_choice
     else :
         # checking from arguments (GET)
         # get previous total choices in the form, if exist
         previous = int(self.args[1])if len (self.args) == 2 else 0
         context['add_choices'] = int(self.args[0]) + previous if len(self.args) > 0 else 0
     
     return context 
コード例 #13
0
ファイル: views.py プロジェクト: copasi/cloud-copasi
 def get_context_data(self, **kwargs):
     context = FormView.get_context_data(self, **kwargs)
     context['page_title'] = self.page_title
     return context
コード例 #14
0
ファイル: account_views.py プロジェクト: edkent/cloud-copasi
 def get_context_data(self, **kwargs):
     context = FormView.get_context_data(self, **kwargs)
     context['page_title'] = self.page_title
     context['allow_new_registrations'] = settings.ALLOW_NEW_REGISTRATIONS
     return context
コード例 #15
0
 def get_context_data(self, **kwargs):
     context = FormView.get_context_data(self, **kwargs)
     context['page_title'] = self.page_title
     return context
コード例 #16
0
 def get_context_data(self, **kwargs):
     context = FormView.get_context_data(self, **kwargs)
     context['page_title'] = self.page_title
     context['allow_new_registrations'] = settings.ALLOW_NEW_REGISTRATIONS
     return context
コード例 #17
0
ファイル: views.py プロジェクト: acaciawater/acaciadata
 def get_context_data(self, **kwargs):
     context = FormView.get_context_data(self, **kwargs)
     context['network'] = Network.objects.first()
     return context