コード例 #1
0
ファイル: views.py プロジェクト: mgov-tech/rapidpro
        def derive_initial(self):
            initial = super().derive_initial()
            org = self.request.user.get_org()

            urn_ids = [
                _ for _ in self.request.GET.get("u", "").split(",") if _
            ]
            msg_ids = [
                _ for _ in self.request.GET.get("m", "").split(",") if _
            ]
            contact_uuids = [
                _ for _ in self.request.GET.get("c", "").split(",") if _
            ]

            if msg_ids or contact_uuids or urn_ids:
                params = {}
                if len(msg_ids) > 0:
                    params["m"] = ",".join(msg_ids)
                if len(contact_uuids) > 0:
                    params["c"] = ",".join(contact_uuids)
                if len(urn_ids) > 0:
                    params["u"] = ",".join(urn_ids)

                results = omnibox_query(org, **params)
                initial["omnibox"] = omnibox_results_to_dict(org,
                                                             results,
                                                             version=2)

            initial["step_node"] = self.request.GET.get("step_node", None)
            return initial
コード例 #2
0
 def derive_initial(self):
     org = self.object.org
     results = [*self.object.groups.all(), *self.object.contacts.all()]
     selected = omnibox_results_to_dict(org, results, version="2")
     message = self.object.text[self.object.base_language]
     return dict(message=message, omnibox=selected)