Esempio n. 1
0
class AlumniSerializer(serializers.ModelSerializer):
    first_name = serializers.SerializerMethodField()
    last_name = serializers.SerializerMethodField()
    email = serializers.SerializerMethodField()
    college = CollegeSerializer(read_only=True)
    major = MajorSerializer(read_only=True)
    company = CompanyBasicsSerializer(read_only=True)
    country = CountrySerializer(read_only=True)
    state = StateSerializer(read_only=True)
    job_position = JobPositionSerializer(read_only=True)

    def get_first_name(self, obj):
        return obj.user.first_name

    def get_last_name(self, obj):
        return obj.user.last_name

    def get_email(self, obj):
        return obj.user.email

    class Meta:
        model = Profile
        fields = ('id', 'first_name', 'last_name', 'email', 'college', 'major',
                  'company', 'country', 'state', 'job_position',
                  'profile_photo_social', 'profile_photo_custom', 'grad_year')
Esempio n. 2
0
class ProfileSerializer(serializers.ModelSerializer):
    user = UserSerializer(read_only=True)
    emp_status = EmploymentStatusSerializer(read_only=True)
    college = CollegeSerializer(read_only=True)
    major = MajorSerializer(read_only=True)
    company = CompanyBasicsSerializer(read_only=True)
    country = CountrySerializer(read_only=True)
    state = StateSerializer(read_only=True)
    job_position = JobPositionSerializer(read_only=True)
    dob = serializers.DateField(format="%Y-%m-%d")
    is_google_linked = serializers.SerializerMethodField()
    is_linkedin_linked = serializers.SerializerMethodField()

    def get_is_google_linked(self, obj):
        if obj.social_auth.filter(provider='google-oauth2').count() == 0:
            return False
        return True

    def get_is_linkedin_linked(self, obj):
        if obj.social_auth.filter(provider='linkedin-oauth2').count() == 0:
            return False
        return True

    class Meta:
        model = User
        exclude = [
            'password', 'last_login', 'is_superuser', 'is_staff', 'is_active',
            'is_demo', 'activation_key', 'key_expires', 'forgot_password_key',
            'forgot_password_key_expires', 'approved', 'groups',
            'user_permissions'
        ]
Esempio n. 3
0
class AlumniSerializer(serializers.ModelSerializer):
    college = CollegeSerializer(read_only=True)
    major = MajorSerializer(read_only=True)
    company = CompanyBasicsSerializer(read_only=True)
    country = CountrySerializer(read_only=True)
    state = StateSerializer(read_only=True)
    job_position = JobPositionSerializer(read_only=True)

    class Meta:
        model = get_user_model()
        fields = (
            'id', 'first_name', 'last_name', 'email', 'college', 'major', 'company', 'country', 'state', 'job_position',
            'profile_photo', 'grad_year')
Esempio n. 4
0
def company_locations(request):
    if request.user.user_type.name == 'Career Service':
        User = get_user_model()
        college_users = User.objects.filter(
            id__in=[p.id for p in User.objects.filter(college=request.user.college, is_demo=False)])
        jobapps = JobApplication.objects.filter(~Q(company_object__location_address=None),
                                                user__in=college_users, is_deleted=False).distinct('company_object')
    else:
        jobapps = JobApplication.objects.filter(~Q(company_object__location_address=None), user=request.user,
                                                is_deleted=False).distinct('company_object')
    companies = []
    for jobapp in jobapps:
        companies.append(jobapp.company_object)
    return JsonResponse(
        create_response(
            data=CompanyBasicsSerializer(instance=companies, many=True, context={'user': request.user}).data),
        safe=False)
Esempio n. 5
0
def companies(request):
    user_profile = Profile.objects.get(user=request.user)
    if user_profile.user_type < int(Profile.UserTypes.student):
        return JsonResponse(create_response(
            data=None,
            success=False,
            error_code=ResponseCodes.not_supported_user),
                            safe=False)
    college = College.objects.get(pk=user_profile.college.pk)
    alumni = Profile.objects.filter(~Q(major=None), college=college)
    data = []
    for a in alumni:
        if a.company is not None:
            data.append(a.company)
    data = set(data)
    serialized_companies = CompanyBasicsSerializer(
        instance=data,
        many=True,
    ).data
    return JsonResponse(create_response(data=serialized_companies), safe=False)
Esempio n. 6
0
class AlumniSerializer(serializers.ModelSerializer):
    college = CollegeSerializer(read_only=True)
    major = MajorSerializer(read_only=True)
    company = CompanyBasicsSerializer(read_only=True)
    country = CountrySerializer(read_only=True)
    state = StateSerializer(read_only=True)
    job_position = JobPositionSerializer(read_only=True)
    email = serializers.SerializerMethodField()

    def get_email(self, obj):
        if obj.is_email_public:
            return obj.email
        else:
            return None

    class Meta:
        model = get_user_model()
        fields = ('id', 'first_name', 'last_name', 'email', 'college', 'major',
                  'company', 'country', 'state', 'job_position',
                  'profile_photo', 'grad_year')