Ejemplo n.º 1
0
 def mutate(self, info, public_key, key_name):
     user = get_user_from_info(info)
     try:
         result = EncryptionKeyService.add_key(user, public_key, key_name)
     except EncryptionKeyService.exceptions as e:
         raise MutationExecutionException(str(e))
     return SubmitEncryptionKey(success=True, encryption_key=result)
Ejemplo n.º 2
0
 def mutate(self, info, form_id, content):
     try:
         result = FormService.submit(int(from_global_id(form_id)[1]),
                                     content)
     except FormService.exceptions as e:
         raise MutationExecutionException(str(e))
     return SubmitForm(success=True, **result)
Ejemplo n.º 3
0
 def mutate(self, info, schema_id, schema):
     user = get_user_from_info(info)
     try:
         result = FormSchemaService.update_form_schema(user, schema_id, schema)
     except FormSchemaService.exceptions as e:
         raise MutationExecutionException(str(e))
     return UpdateFormSchema(success=True, form_schema=result)
Ejemplo n.º 4
0
 def mutate(self, info, name, description):
     user = get_user_from_info(info)
     try:
         result = FormService.create_form_(user, name, description)
     except FormSchemaService.exceptions as e:
         raise MutationExecutionException(str(e))
     return CreateForm(success=True, form=result)
Ejemplo n.º 5
0
    def mutate(cls,
               root,
               info,
               trip_type=NotPassed,
               day_time_frame=NotPassed,
               time_frame=NotPassed,
               ended_at_station=NotPassed,
               started_at_station=NotPassed):
        query_data = {}
        if trip_type != NotPassed:
            query_data['trip_type'] = trip_type
        if day_time_frame != NotPassed:
            query_data['day_time_frame'] = day_time_frame
        if ended_at_station != NotPassed:
            query_data['ended_at_station'] = ended_at_station
        if started_at_station != NotPassed:
            query_data['started_at_station'] = started_at_station
        if time_frame != NotPassed:
            query_data['time_frame'] = time_frame

        try:
            print(query_data)
            query = DataExplorationService.query_filter(**query_data)
        except DataExplorationService.exceptions as e:
            raise MutationExecutionException(str(e))

        return cls.process_query(query)
Ejemplo n.º 6
0
 def mutate(self, info, public_key_id):
     user = get_user_from_info(info)
     try:
         result = EncryptionKeyService.remove_key(
             user, int(from_global_id(public_key_id)[1]))
     except EncryptionKeyService.exceptions as e:
         raise MutationExecutionException(str(e))
     return RemoveEncryptionKey(success=True)
Ejemplo n.º 7
0
 def mutate(self, info, schema, key, form_id):
     user = get_user_from_info(info)
     try:
         result = FormSchemaService.create_or_update_form_schema(
             user, key, int(from_global_id(form_id)[1]), schema)
     except FormSchemaService.exceptions as e:
         raise MutationExecutionException(str(e))
     return CreateOrUpdateFormSchema(success=True, form_schema=result)
Ejemplo n.º 8
0
    def mutate(self, info, **kwargs):
        user = get_user_from_info(info)

        try:
            user = UserProfileService.update_user_basic_information(user=user,
                                                                    **kwargs)
        except UserProfileService.exceptions as e:
            raise MutationExecutionException(str(e))
        return UpdateMyUserProfile(me=user, success=True)
Ejemplo n.º 9
0
    def mutate(self, info, **kwargs):
        user = get_user_from_info(info)
        file_ = kwargs["profile_picture"]

        try:
            user = UserProfileService.upload_profile_picture(user=user,
                                                             picture=file_)
        except UserProfileService.exceptions as e:
            raise MutationExecutionException(str(e))
        return UploadProfilePicture(me=user, success=True)
Ejemplo n.º 10
0
 def mutate(self, info, public_key_id, keys):
     c_keys = {}
     for key in keys:
         c_keys[int(from_global_id(key["membership_id"])[1])] = key["key"]
     user = get_user_from_info(info)
     try:
         result = EncryptionKeyService.activate_key(
             user, int(from_global_id(public_key_id)[1]), keys=c_keys)
     except EncryptionKeyService.exceptions as e:
         raise MutationExecutionException(str(e))
     return ActivateEncryptionKey(success=True, encryption_key=result)
Ejemplo n.º 11
0
 def mutate(self, info, team_id, affected_user_id):
     user = get_user_from_info(info)
     try:
         result = TeamMembershipService.remove_member(
             user,
             team_id=int(from_global_id(team_id)[1]),
             affected_user_id=int(from_global_id(affected_user_id)[1]),
         )
     except TeamMembershipService.exceptions as e:
         raise MutationExecutionException(str(e))
     return RemoveTeamMember(success=True)
Ejemplo n.º 12
0
 def mutate(self, info, name, keys):
     user = get_user_from_info(info)
     c_keys = {}
     for key in keys:
         c_keys[int(from_global_id(
             key["encryption_key_id"])[1])] = key["key"]
     try:
         result = TeamService.create(user, name=name, keys=c_keys)
     except TeamService.exceptions as e:
         raise MutationExecutionException(str(e))
     return CreateTeam(success=True, team=result)
Ejemplo n.º 13
0
 def mutate(self, info, translation_id, key, value):
     user = get_user_from_info(info)
     try:
         result = FormTranslationService.update_translation_string(
             user,
             translation_id=int(from_global_id(translation_id)[1]),
             key=key,
             value=value,
         )
     except FormTranslationService.exceptions as e:
         raise MutationExecutionException(str(e))
     return UpdateFormTranslationKey(success=True, translation_key=result)
Ejemplo n.º 14
0
 def mutate(self, info, form_id, language, region):
     user = get_user_from_info(info)
     try:
         result = FormTranslationService.create_form_translation(
             user,
             form_id=int(from_global_id(form_id)[1]),
             language=language,
             region=region,
         )
     except FormTranslationService.exceptions as e:
         raise MutationExecutionException(str(e))
     return CreateFormTranslation(success=True, form_translation=result)
Ejemplo n.º 15
0
 def mutate(self, info, public_key, csr, team_id):
     user = get_user_from_info(info)
     try:
         result = TeamService.add_csr(
             user,
             team_id=int(from_global_id(team_id)[1]),
             public_key=public_key,
             csr=csr,
         )
     except TeamService.exceptions as e:
         raise MutationExecutionException(str(e))
     return AddCSRForTeam(success=True, team=result)
Ejemplo n.º 16
0
 def mutate(self, info, keys, team_id, invited_user_id, role):
     user = get_user_from_info(info)
     c_keys = {}
     for key in keys:
         c_keys[int(from_global_id(
             key["encryption_key_id"])[1])] = key["key"]
     try:
         result = TeamMembershipService.add_member(
             user,
             keys=c_keys,
             team_id=int(from_global_id(team_id)[1]),
             invited_user_id=int(from_global_id(invited_user_id)[1]),
             role=role,
         )
     except TeamMembershipService.exceptions as e:
         raise MutationExecutionException(str(e))
     return AddTeamMember(success=True, membership=result)
Ejemplo n.º 17
0
 def mutate(self,
            info,
            form_id,
            name=NotPassed,
            description=NotPassed,
            xml_code=NotPassed,
            js_code=NotPassed,
            active=NotPassed):
     user = get_user_from_info(info)
     try:
         result = FormService.update_form_(
             user,
             int(from_global_id(form_id)[1]),
             name=name,
             description=description,
             xml_code=xml_code,
             js_code=js_code,
             active=active,
         )
     except FormSchemaService.exceptions as e:
         raise MutationExecutionException(str(e))
     return UpdateForm(success=True, form=result)