Ejemplo n.º 1
0
 def render_authenticated_user(self, request):
     csp = ChangesetProtocol()
     data = {
         "a_changesets": ["updates", "deletes", "inserts"],
         "sh_changesets": ["deletes"],
     }
     request.POST = MultiValueDict({"data": [json.dumps(data)]})
     response = csp.dispatch(request, action="dashboard")
     response = json.loads(response.content.decode())
     public = get_public_deal_count()
     overall = get_overall_deal_count()
     data = {
         "statistics": {
             "overall_deal_count": overall,
             "public_deal_count": public,
             "not_public_deal_count": overall - public
         },
         "view": "dashboard",
         "latest_added": response["latest_added"],
         "latest_modified": response["latest_modified"],
         "latest_deleted": response["latest_deleted"],
         "manage": response["manage"],
         "feedbacks": response["feedbacks"],
     }
     return render_to_response(self.template_name, data,
                               RequestContext(request))
Ejemplo n.º 2
0
    def render_authenticated_user(self, request):
        csp = ChangesetProtocol()
        request.POST = MultiValueDict({
            "data": [
                json.dumps({
                    "a_changesets":
                    ["updates", "deletes", "inserts", "rejected"],
                    "sh_changesets": ["deletes"]
                })
            ]
        })
        response = csp.dispatch(request, action="list")
        response = json.loads(response.content.decode())
        data = {"view": "manage"}

        data.update(response.get("a_changesets", {}))

        if "updates" in data and data["updates"] and data["updates"]["cs"]:
            changed = []
            for cs in data["updates"]["cs"]:
                for k in cs.get("fields_changed", []):
                    changed.append(str(get_field_by_a_key_id(k).label))
                cs["fields_changed"] = ", ".join(changed)

        data.update({
            "sh_deletes":
            response.get("sh_changesets", {}).get("deletes", {})
        })
        data.update({"feedbacks": response.get("feedbacks", [])})
        data.update({"rejected": response.get("rejected", [])})

        return render_to_response(self.template_name,
                                  data,
                                  context_instance=RequestContext(request))
Ejemplo n.º 3
0
    def dispatch(self, request, *args, **kwargs):

        self._set_filters(request.GET)

        context = self.get_context_data(**kwargs)
        self.add_filter_context_data(context, request)

        return render_to_response(self.template_name, context,
                                  RequestContext(request))
 def dispatch(self, request, activity_1, activity_2=None):
     deal_1 = HistoricalActivity.objects.get(pk=activity_1)
     if activity_2:
         deal_2 = HistoricalActivity.objects.get(pk=activity_2)
     else:
         deal_2 = HistoricalActivity.objects.filter(activity_identifier=deal_1.activity_identifier)\
             .filter(history_date__lt=deal_1.history_date).order_by('history_date').last()
     context = super().get_context_data()
     context['deals'] = [deal_1, deal_2]
     context['forms'] = get_comparison(deal_1, deal_2, user=request.user)
     return render_to_response('deal-comparison.html', context, RequestContext(request))
Ejemplo n.º 5
0
 def dispatch(self, request, activity_1, activity_2=None):
     deal_1 = HistoricalActivity.objects.get(pk=activity_1)
     if activity_2:
         deal_2 = HistoricalActivity.objects.get(pk=activity_2)
     else:
         deal_2 = HistoricalActivity.objects.filter(activity_identifier=deal_1.activity_identifier)\
             .filter(history_date__lt=deal_1.history_date).order_by('history_date').last()
     context = super().get_context_data()
     context['deals'] = [deal_1, deal_2]
     context['forms'] = get_comparison(deal_1, deal_2)
     return render_to_response('deal-comparison.html', context,
                               RequestContext(request))
    def dispatch(self, request, investor_1, investor_2=None):
        hinvestor_1 = HistoricalInvestor.objects.get(pk=investor_1)
        if investor_2:
            hinvestor_2 = HistoricalInvestor.objects.get(pk=investor_2)
        else:
            hinvestor_2 = HistoricalInvestor.objects.filter(
                investor_identifier=hinvestor_1.investor_identifier) \
                .filter(history_date__lt=hinvestor_1.history_date).order_by('history_date').last()
        context = super().get_context_data()
        context['investors'] = [hinvestor_1, hinvestor_2]
        context['forms'] = get_comparison(hinvestor_1, hinvestor_2)

        return render_to_response('investor-comparison.html', context, RequestContext(request))
Ejemplo n.º 7
0
    def dispatch(self, request, *args, **kwargs):
        investor_1_id = kwargs.pop('investor_1', None)
        if investor_1_id is None:
            raise RuntimeError('investor_1 needed. Got ' + str(kwargs))
        if '_' in investor_1_id:
            investor_1 = _investor_from_id_and_timestamp(investor_1_id)
        else:
            investor_1 = Investor.objects.get(pk=investor_1_id).history.last()
        investor_2 = previous_history_state(investor_1)
        context = super().get_context_data(**kwargs)
        context['investors'] = [investor_1, investor_2]
        context['comparison_forms'] = get_comparison(investor_1, investor_2)

        return render_to_response(
            'investor-comparison.html', context, RequestContext(request))
Ejemplo n.º 8
0
    def dispatch(self, request, *args, **kwargs):
        try:
            investor = investor_from_id(kwargs["investor_id"])
        except KeyError:
            investor = None

        context = super(StakeholderView, self).get_context_data(**kwargs)
        context['investor'] = investor
        context['investor_form'] = InvestorForm(
            InvestorForm.get_data(investor))
        context['parent_stakeholders'] = ParentStakeholderFormSet(
            initial=ParentStakeholderFormSet.get_data(investor, role='ST'),
            prefix='parent-stakeholder-form')
        context['parent_investors'] = ParentInvestorFormSet(
            initial=ParentInvestorFormSet.get_data(investor, role='IN'),
            prefix='parent-investor-form')

        if request.POST:
            save_from_post(request.POST)

        return render_to_response(self.template_name, context,
                                  RequestContext(request))
Ejemplo n.º 9
0
    def dispatch(self, request, *args, **kwargs):
#        print('dispatch kwargs:', kwargs)
        activity_1_id = kwargs.pop("activity_1_id", None)
        if activity_1_id is not None:
            deal_1 = deal_from_activity_id(activity_1_id)
            activity_2_id = kwargs.pop("activity_2_id", None)
            if activity_2_id is None:
                raise RuntimeError('Either activity_1_id AND activity_2_id or activity_1 needed. Got ' + str(kwargs))
            deal_2 = deal_from_activity_id(activity_2_id)
            deal_id = activity_1_id
        else:
            activity_1 = kwargs.pop('activity_1', None)
            if activity_1 is None:
                raise RuntimeError('Either activity_1_id AND activity_2_id or activity_1 needed. Got ' + str(kwargs))
            deal_1 = deal_from_activity_id_and_timestamp(activity_1)
            deal_2 = previous_history_state(deal_1)
            deal_id = activity_1

        context = super().get_context_data(deal_id, **kwargs)
        context['deals'] = [deal_1, deal_2]
        context['forms'] = get_comparison(deal_1, deal_2)

        return render_to_response('deal-comparison.html', context, RequestContext(request))
Ejemplo n.º 10
0
 def render_forms(self, request, context):
     return render_to_response(self.template_name, context,
                               RequestContext(request))
Ejemplo n.º 11
0
 def render_forms(self, request, context):
     return render_to_response(self.template_name, context, RequestContext(request))