def get_data(self, opportunity, user):
     data = {}
     user_wrapper = UserWrapper(user=user)
     data['user_from_full_name'] = user_wrapper.get_full_name()
     data['user_from_title'] = user_wrapper.userTitle
     data['user_from_profile_picture'] = user_wrapper.profilePicture[1][1]
     data['title'] = '{} started a new conversation related to {}'.format(
         user_wrapper.get_full_name(), opportunity.title)
     return data
 def get_speakers(self, obj):
     data = []
     speakers = obj.participants.filter_by_role_name(
         settings.EVENT_SPEAKER_NAME)
     for participant in speakers:
         user_wrapper = UserWrapper(user=participant.user)
         value = {
             'name':
             user_wrapper.get_full_name(),
             'profile_url':
             '{}{}'.format(
                 settings.DOMAIN_NAME,
                 user_wrapper.profile_url,
             ),
             'bio':
             user_wrapper.bio_me,
             'linkedin':
             user_wrapper.linkedin,
             'profile_picture':
             user_wrapper.profile_picture_96,
             'title':
             user_wrapper.user_title
         }
         data.append(value)
     return data
 def get_data(self):
     data = super().get_data()
     user_wrapper = UserWrapper(user=self.applicant.user)
     data.update({
         'applicant_name': user_wrapper.get_full_name(),
     })
     return data
Beispiel #4
0
 def send_email(self, user, conversations, period):
     user_wrapper = UserWrapper(user=user)
     data = {}
     if period == DAILY:
         data['subject_args'] = {'period': 'Daily'}
     else:
         data['subject_args'] = {'period': 'Weekly'}
     data['total'] = sum(map(lambda x: x[1].count(), conversations))
     data['name'] = user_wrapper.get_full_name()
     data['conversations'] = []
     for conversation, messages in conversations:
         url, related_title = get_info_related(conversation, user)
         data_conversation = {}
         data_conversation['total'] = messages.count()
         data_conversation['message'] = messages.first().message
         data_conversation['url'] = url
         title = CONVERSATION_TITLE.get(
             conversation._type).format(related_title)
         data_conversation['title'] = title
         data['conversations'].append(data_conversation)
     data['recipients'] = [user_wrapper.email]
     status = mail_handler.send_mail(template=EMAIL_NAME, **data)
     if not status:
         logger.error('Error sending email to: {}'.format(data))
         raise Exception('Error sending email to: {}'.format(data))
Beispiel #5
0
def get_info_related(conversation, user_from):

    if conversation._type == settings.CONVERSATIONS_CH_USER:
        other_user = conversation.users.exclude(user=user_from).first()
        user_wrapper = UserWrapper(user=other_user)
        url = user_wrapper.profile_url
        title = user_wrapper.get_full_name()

    elif conversation._type == settings.CONVERSATIONS_CH_PROJECT:
        project_uuid = conversation.uuid_related_object
        response = get_info_core_project(user_from, project_uuid)
        url = response['chatUrl']
        title = '{} ({})'.format(response['name'], conversation.name)

    elif conversation._type == settings.CONVERSATIONS_CH_EXO_PROJECT:
        project_uuid = conversation.uuid_related_object
        response = get_info_exo_project(user_from, project_uuid)
        url = response['chatUrl']
        title = '{} ({})'.format(response['name'], conversation.name)

    elif conversation._type == settings.CONVERSATIONS_CH_OPPORTUNITIES:
        opportunity_uuid = conversation.uuid_related_object
        response = get_info_opportunities(user_from, opportunity_uuid)
        url = response['chatUrl']
        title = response['title']
    return url, title
Beispiel #6
0
    def get_data(self):
        data = super().get_data()
        user_wrapper = UserWrapper(user=self.applicant.user)
        answers = [
            {
                'question': answer.question.title,
                'response': answer.response,
                'response_text': answer.response_text
            }
            for answer in self.applicant.answers.all()
        ]

        data.update({
            'applicant_profile_picture': user_wrapper.get_profile_picture(settings.LARGE_IMAGE_SIZE),
            'applicant_name': user_wrapper.get_full_name(),
            'applicant_role': user_wrapper.user_title,
            'summary': self.applicant.summary,
            'questions_extra_info': self.applicant.questions_extra_info,
            'applicant_email': user_wrapper.email,
            'applicant_profile_url': user_wrapper.profile_url,
            'public_url': self.opportunity.admin_url_public,
            'answers': answers,
            'reply_to': [
                user_wrapper.email,
            ],

        })
        return data
def create_conversation(opportunity, users):
    user_from = users[-1]
    user_wrapper = UserWrapper(user=user_from)
    icon = user_wrapper.profile_picture[1][1]
    group_name = user_wrapper.get_full_name()
    users_to = [add_user(user) for user in users]
    return group_name, users_to, icon
Beispiel #8
0
 def get_data(self):
     data = super().get_data()
     user_wrapper = UserWrapper(user=self.user)
     data.update({
         'applicant_name': user_wrapper.get_full_name(),
         'public_url': settings.OPPORTUNITIES_PUBLIC_URL,
     })
     return data
Beispiel #9
0
def add_user(user, project, team=None):
    user_wrapper = UserWrapper(user=user)
    return {
        'name': user_wrapper.get_full_name(),
        'profile_picture': user_wrapper.profile_picture[1][1],
        'short_title': get_user_title_in_project(project, user, team),
        'profile_url': user_wrapper.profile_url,
        'user_uuid': str(user.uuid),
    }
Beispiel #10
0
    def get_data(self):
        user_wrapper = UserWrapper(user=self.opportunity.created_by)

        return {
            'title': self.opportunity.title,
            'created_by_profile_picture': user_wrapper.get_profile_picture(settings.MEDIUM_IMAGE_SIZE),
            'created_by_name': user_wrapper.get_full_name(),
            'created_by_role': user_wrapper.user_title,
            'role': self.opportunity.role_string,
            'category_code': self.opportunity.category.code,
        }
Beispiel #11
0
def get_feedback_from_objects(team_step, objects):
    results = []
    sum_rate = 0
    sum_feelings = 0
    sum_comments = 0
    average_rate = 0
    average_feeling = 0
    total_reviews = 0
    total_reviewers = objects.count()

    for user in objects:
        comment = None
        rate = team_step.get_rating_for_user(user)
        feeling = team_step.get_feedback_for_user(user)

        if rate and feeling:
            total_reviews += 1
            sum_rate += rate
            sum_feelings += feeling

            last_feedback_action = team_step.get_last_action_feedback(
                user=user, verb=settings.TEAM_ACTION_COMMENT_WEEKLY)

            if last_feedback_action and last_feedback_action.description:
                sum_comments += 1
                comment = {
                    'text': last_feedback_action.description,
                    'date': last_feedback_action.timestamp,
                }

            user_wrapper = UserWrapper(user=user)
            result = {
                'fullName': user_wrapper.get_full_name(),
                'thumbnail': user_wrapper.profile_picture_96,
                'feeling': team_step.get_feedback_for_user(user),
                'rate': team_step.get_rating_for_user(user),
                'comment': comment,
            }

            results.append(result)

    if total_reviews:
        average_rate = round(sum_rate / total_reviews, 1)
        average_feeling = round(sum_feelings / total_reviews, 0)

    data = {
        'average_rate': average_rate,
        'average_feelings': average_feeling,
        'total_reviewers': total_reviewers,
        'total_comments': sum_comments,
        'results': results,
    }

    return data
Beispiel #12
0
 def run(self, user_uuid, *args, **kwargs):
     user_wrapper = UserWrapper(uuid=user_uuid)
     mail_kwargs = {
         'user_full_name': user_wrapper.get_full_name(),
         'user_profile_url': user_wrapper.profile_url,
         'comments': kwargs.get('comment', ''),
     }
     mail_handler.send_mail(
         template='event_summit_notification',
         recipients=[settings.EVENT_SUMMIT_DISTRIBUTION_LIST_EMAIL],
         **mail_kwargs,
     )
def add_user(user):
    if isinstance(user, dict):
        uuid = user['uuid'].__str__()
        user_wrapper = UserWrapper(uuid)
    else:
        user_wrapper = UserWrapper(user=user)
        uuid = user.uuid.__str__()
    return {
        'name': user_wrapper.get_full_name(),
        'profile_picture': user_wrapper.profile_picture[1][1],
        'short_title': user_wrapper.user_title,
        'profile_url': user_wrapper.profile_url,
        'user_uuid': uuid,
    }
    def get_data(self):
        data = super().get_data()

        user_wrapper = UserWrapper(user=self.user)

        data.update({
            'location': self.project.location,
            'user_name': user_wrapper.get_full_name(),
            'email': user_wrapper.email,
            'public_url': self.project.url_zone(self.user),
            'subject_args': {
                'name': self.project.name,
            }
        })
        return data
    def get_data(self):
        data = super().get_data()

        user_wrapper = UserWrapper(user=self.user)

        data.update({
            'start_date': self.project.start.strftime('%d-%m-%Y'),
            'user_name': user_wrapper.get_full_name(),
            'email': user_wrapper.email,
            'public_url': self.project.url_zone(self.user),
            'subject_args': {
                'name': self.project.name,
                'start_date': self.project.start.strftime('%d-%m-%Y'),
            }
        })
        return data
Beispiel #16
0
 def get_data(self):
     data = super().get_data()
     user_wrapper = UserWrapper(user=self.applicant.user)
     file = self.applicant.get_ics_event()
     data.update({
         'applicant_name':
         user_wrapper.get_full_name(),
         'comment':
         self.applicant.response_message,
         'public_url':
         '/ecosystem/opportunities/{}'.format(self.opportunity.pk),
         'opportunity_url':
         '/ecosystem/opportunities/{}'.format(self.opportunity.pk),
         'start_date_full':
         self.applicant.start_date_full,
         'attachments': [file] if file else [],
     })
     return data
Beispiel #17
0
    def get_data(self):
        data = super().get_data()

        user_wrapper = UserWrapper(user=self.user)
        roles = self.user.user_team_roles.filter(team=self.team).values_list(
            'team_role__role', flat=True)
        roles = ', '.join(list(roles))
        data.update({
            'roles': roles,
            'team_name': self.team.name,
            'user_name': user_wrapper.get_full_name(),
            'email': user_wrapper.email,
            'public_url': self.project.url_zone(self.user),
            'subject_args': {
                'team_name': self.team.name,
                'roles': roles,
            }
        })
        return data
Beispiel #18
0
 def create(self, validated_data):
     event = validated_data.get('event')
     user_wrapper = UserWrapper(user=validated_data.get('user'))
     instance = Participant.objects.create(
         event=event,
         created_by=validated_data.get('user_from'),
         user=validated_data.get('user'),
         exo_role=validated_data.get('exo_role'),
         order=event.participants.count(),
         user_name=user_wrapper.get_full_name(),
         user_email=user_wrapper.email,
     )
     OpportunityParticipant.objects.create(
         participant=instance,
         opportunity_uuid=validated_data.get('opportunity_uuid'))
     job = instance.job
     job.delete()
     Job.objects.update_or_create(participant=instance)
     return instance
Beispiel #19
0
 def get_data(self, user_from):
     event_owner = UserWrapper(user=self.event.created_by)
     data = {
         'name':
         '{name} - {location}'.format(
             name=self.event.title,
             location=self.event.location_for_certification),
         'description':
         self.event.description_for_certification,
         'content_object':
         self.event,
         'instructor_name':
         event_owner.get_full_name(),
         '_type':
         settings.CERTIFICATION_CH_GROUP_WORKSHOP,
         'created_by':
         user_from,
     }
     data['issued_on'] = self.event.start
     data['course_name'] = self.event.title
     return data
Beispiel #20
0
    def get_data(self):
        user_wrapper = UserWrapper(user=self.opportunity.created_by)

        return {
            'title':
            self.opportunity.title,
            'created_by_profile_picture':
            user_wrapper.get_profile_picture(settings.MEDIUM_IMAGE_SIZE),
            'created_by_name':
            user_wrapper.get_full_name(),
            'created_by_user_title':
            user_wrapper.user_title,
            'recipient_name':
            self.user_recipient.get('full_name'),
            'public_url':
            self.opportunity.url_public,
            'role':
            self.opportunity.role_string,
            'disable_notification_url':
            self.user_recipient.get('disable_notification_url'),
        }
    def get_data(self):
        data = super().get_data()

        user_wrapper = UserWrapper(user=self.user)

        roles = list(self.user.user_project_roles.filter(
            project_role__project=self.project).values_list(
            'project_role__exo_role__name', flat=True))
        roles = ', '.join(roles)
        data.update({
            'roles': roles,
            'user_name': user_wrapper.get_full_name(),
            'email': user_wrapper.email,
            'start_date': self.project.start.strftime('%d-%m-%Y'),
            'public_url': self.project.url_zone(self.user),
            'subject_args': {
                'roles': roles,
                'name': self.project.name,
            }
        })
        return data