Beispiel #1
0
    def find_all_templates() -> Template:
        template = Template()

        queryset = Template.objects().order_by('-_id')

        template_collection = []
        for template_obj in queryset:

            taglist = []
            for tag in template_obj['tags']:
                taglist.append(tag)
            user = UserModel.finduser_by_user_id(
                template_obj.templatecreator_id)
            if user:
                t_creator_name = user['username']
            else:
                t_creator_name = "Anonymous"

            template_object = {
                'template_id': template_obj._id,
                'template_name': template_obj.name,
                'templatecreator_id': template_obj.templatecreator_id,
                't_creator_name': t_creator_name,
                'taglist': taglist
            }
            template_collection.append(template_object)

        return template_collection
Beispiel #2
0
    def getcounter():
        template = Template()
        counter = 1
        firsttemplate = Template.objects().order_by('-_id').first()
        if firsttemplate:
            counter = (firsttemplate._id) + 1

        return counter
Beispiel #3
0
    def responsemapper(queriedtemplate):
        responsetemplate = [{
            'template_id': queriedtemplate._id,
            'template_name': queriedtemplate.name,
            "tags": []
        }]
        tabquestions = []
        responsetemplate['_id':queriedtemplate._id]
        responsetemplatetags = []
        for tags in queriedtemplate.tags:
            responsetemplatetags.append(tags)

        responsetabs = []
        for tabs in queriedtemplate.tabs:
            tab_questions = []
            for question in queriedtemplate.tabs.tabquestions:
                response_options = []
                for response in queriedtemplate.tabs.tabquestions.responseoptions:
                    response_question = [{
                        'q_id': question.q_id,
                        'q_text': question.q_text,
                        'responseoptions': []
                    }]
            response_tab = [{'tabname': tabs.tabname, 'tab_questions': []}]
            responsetabs.append()
        responsearray = []
        template = Template()
        template.name = data['template_name']

        temp_taglist = []
        for tag in data['tags']:
            temp_taglist.append(tag)

        template.tags = temp_taglist

        temp_tablist = []
        for tab in data['tabs']:
            tabobject = Tabstructure()
            tabobject.tabname = tab['tabname']
            tabquestionobjectlist = []
            for tabitem in tab['tabquestions']:
                tabquestionobject = TabQuestion()
                tabquestionobject.q_id = tabitem['q_id']
                tabquestionobject.q_text = tabitem['q_text']
                responseoptions = []
                for resoption in tabitem['q_responseoptions']:
                    responseoptions.append(resoption)
                tabquestionobject.q_responseoptions = responseoptions
                tabquestionobjectlist.append(tabquestionobject)
            tabobject.tabquestions = tabquestionobjectlist
            temp_tablist.append(tabobject)

        template.tabs = temp_tablist

        return template
Beispiel #4
0
    def find_by_templatename(templatename) -> Template:

        existingtemplateobject = Template.objects(name=templatename).first()
        if existingtemplateobject:
            templateobject = existingtemplateobject.to_json()
            return templateobject
        else:
            return existingtemplateobject
Beispiel #5
0
    def find_by_templateid(templateid) -> Template:

        templateobject = Template.objects(_id=templateid).first()

        if templateobject:
            pprint(templateobject.name)
        else:
            templateobject = None
        return templateobject
Beispiel #6
0
    def requestmapper(data) -> Template:

        template = Template()
        template.name = data['template_name']

        temp_taglist = []
        for tag in data['tags']:
            temp_taglist.append(tag)

        template.tags = temp_taglist
        template.templatecreator_id = data['templatecreator_id']

        temp_tablist = []
        for tab in data['tabs']:
            tabobject = Tabstructure()
            tabobject.tabname = tab['tabname']
            tabquestionobjectlist = []
            for tabitem in tab['tabquestions']:
                tabquestionobject = TabQuestion()
                tabquestionobject.q_id = tabitem['q_id']
                tabquestionobject.q_text = tabitem['q_text']
                tabquestionobject.q_responsetype = tabitem['q_responsetype']
                if tabquestionobject.q_responsetype == "select":
                    responseoptions = []
                    for resoption in tabitem['q_responseoptions']:
                        responseoptions.append(resoption)
                    tabquestionobject.q_responseoptions = responseoptions
                tabquestionobjectlist.append(tabquestionobject)
            tabobject.tabquestions = tabquestionobjectlist
            temp_tablist.append(tabobject)

        template.tabs = temp_tablist
        return template
Beispiel #7
0
    if style:
        qtargs2.append('-style')
        qtargs2.append(style)

    qtargs2.extend(qtargs or [])
    return QApplication(qtargs2)


fbmbot = Bot(
    "EAAUSZCuERiN4BAIYS7EtOXnnh4k8BC7EJZATEeFQHdOHOujY7g8pbgFZAL5EAiw2plGA5maNACEzX5ZAa0OwuBMq7ZCFog5S9UqbFbzynba7ZBZCBzqOeSMgsrY2AP6X9mRsxiB9ZBVZCVD75d0lIvERh0XMak0t6gUuZCGawc6Yc5nQZDZD"
)
fbmNlp = Nlp()
app_gui = init_qtgui()
bank = BankingModule()
gmaps = GMapsGeocoding()
template = Template()
rasa = RasaConsumer(confident_level=0.3,
                    host='128.199.169.4',
                    port='5000',
                    ssl=False)
app = Celery('fbm_tasksx', backend='amqp', broker='redis://localhost:6379/0')
rasa = RasaConsumer()
mongo = MongoLog()


def create_incoming_msisdn():
    logDtm = (datetime.now() +
              timedelta(hours=0)).strftime('%Y-%m-%d %H:%M:%S')
    incomingMsisdn = [
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, logDtm, -1, -1, 1, -1,
        -1, -1, -1, -1, -1, -1, -1, -1, 0, "2017", "", [], 'no topic'