def update_user(self): cnds = self.navb.conditions() message = '' user = None #print "IDS: ",self.navb.kw, self.navb.kw.get('id') , self.navb.kw.get('pk') if self.navb.kw.get('id') or self.navb.kw.get('pk'): mkw = "%s" % self.navb.kw.get('id') or self.navb.kw.get('pk') cnds = {"indexcol = %s": mkw} user = Enduser.get_users(cnds)[0] if self.navb.kw.get("pk") and self.navb.kw.get( 'nid') and self.navb.kw.get('telephone_moh'): cnds = {"indexcol = %s": self.navb.kw.get("pk")} indexcol = self.navb.kw.get('pk') nid = self.navb.kw.get('nid') phone = self.navb.kw.get('telephone_moh') formdata = { "indexcol": indexcol, "telephone": phone, "national_id": nid, "email": self.navb.kw.get('email'), "surname": self.navb.kw.get('surname'), "given_name": self.navb.kw.get('given_name'), "sex_pk": self.navb.kw.get('sex'), "role_pk": self.navb.kw.get('role'), "education_level_pk": self.navb.kw.get('edu_level'), "date_of_birth": self.navb.make_time(self.navb.kw.get('dob')), "join_date": self.navb.make_time(self.navb.kw.get('djoin')), "language_pk": self.navb.kw.get('language'), "nation_pk": self.navb.kw.get('user_nation'), "province_pk": self.navb.kw.get('user_province'), "district_pk": self.navb.kw.get('user_district'), "referral_facility_pk": self.navb.kw.get('user_hospital'), "facility_pk": self.navb.kw.get('user_facility'), "location_level_pk": self.navb.kw.get('user_area_level'), "sector_pk": self.navb.kw.get('user_sector'), "cell_pk": self.navb.kw.get('user_cell'), "village_pk": self.navb.kw.get('user_village'), "is_active": True, "is_correct": True } #print "\nFORM: ", formdata, "\n" message, user = Enduser.update_user(formdata) if user: user = Enduser.get_users(cnds)[0] self.navb.kw = {"id": self.navb.kw.get("pk")} sectors = self.navb.auth.auth_filter_locations("sec", user.district_pk) cells = self.navb.auth.auth_filter_locations("cel", user.sector_pk) villages = self.navb.auth.auth_filter_locations("vil", user.cell_pk) genders = Enduser.get_genders() roles = Enduser.get_roles() langs = Enduser.get_languages() education_levels = Enduser.get_education_levels() area_levels = Enduser.get_location_levels() #print user.__dict__ return [ sectors, cells, villages, genders, roles, education_levels, area_levels, langs, message, user ]
def register_diagnosis(self): genders = Enduser.get_genders() locs = self.navb.locs() user = self.navb.user area_levels = Enduser.get_location_levels() message = None report = None received = False #print self.navb.kw if self.navb.kw.get('id'): try: report = Malaria.get_report(indexcol=self.navb.kw.get('id')) except Exception, e: print e pass
def register_user(self): cnds = self.navb.conditions() message = '' user = None if self.navb.kw.get("nid") and self.navb.kw.get('telephone_moh'): nid = nid = self.navb.kw.get('nid') phone = self.navb.kw.get('telephone_moh') formdata = { "telephone": phone, "national_id": nid, "email": self.navb.kw.get('email'), "surname": self.navb.kw.get('surname'), "given_name": self.navb.kw.get('given_name'), "sex_pk": self.navb.kw.get('sex'), "role_pk": self.navb.kw.get('role'), "education_level_pk": self.navb.kw.get('edu_level'), "date_of_birth": self.navb.make_time(self.navb.kw.get('dob')), "join_date": self.navb.make_time(self.navb.kw.get('djoin')), "language_pk": self.navb.kw.get('language'), "nation_pk": self.navb.kw.get('user_nation'), "province_pk": self.navb.kw.get('user_province'), "district_pk": self.navb.kw.get('user_district'), "referral_facility_pk": self.navb.kw.get('user_hospital'), "facility_pk": self.navb.kw.get('user_facility'), "location_level_pk": self.navb.kw.get('user_area_level'), "sector_pk": self.navb.kw.get('user_sector'), "cell_pk": self.navb.kw.get('user_cell'), "village_pk": self.navb.kw.get('user_village'), "is_active": True, "is_correct": True } #print "\nFORM: ", formdata, "\n" message, user = Enduser.get_or_create(formdata) self.navb.kw = {} genders = Enduser.get_genders() roles = Enduser.get_roles() langs = Enduser.get_languages() education_levels = Enduser.get_education_levels() area_levels = Enduser.get_location_levels() return [ genders, roles, education_levels, area_levels, langs, message, user ]