def test_profile():
     """Test the dashboard Profile model."""
     bounty = Bounty.objects.create(
         github_url='https://github.com/gitcoinco/web/issues/305',
         web3_created=datetime.now(tz=pytz.UTC),
         expires_date=datetime.now(tz=pytz.UTC) + timedelta(days=1),
         is_open=True,
         raw_data={},
         current_bounty=True,
         bounty_owner_github_username='******',
     )
     tip = Tip.objects.create(
         emails=['*****@*****.**'],
         github_url='https://github.com/gitcoinco/web/issues/305',
         expires_date=datetime.now(tz=pytz.UTC) + timedelta(days=1),
     )
     profile = Profile(
         handle='gitcoinco',
         data={'type': 'Organization'},
     )
     assert str(profile) == 'gitcoinco'
     assert profile.is_org is True
     assert profile.bounties.first() == bounty
     assert profile.tips.first() == tip
     assert profile.desc == '@gitcoinco is a newbie who has participated in 1 funded issue on Gitcoin'
     assert profile.stats == [
         ('newbie', 'Status'),
         (1, 'Total Funded Issues'),
         (1, 'Open Funded Issues'),
         ('0x', 'Loyalty Rate'),
         (0, 'Bounties completed'),
     ]
     assert profile.github_url == 'https://github.com/gitcoinco'
     assert profile.get_relative_url() == '/profile/gitcoinco'
示例#2
0
 def post(self, request):
     serializer = RegisterSerializer(data=request.data)
     data = {}
     if serializer.is_valid():
         email = request.data['email']
         username = request.data['username']
         if email != '':
             email_list = User.objects.filter(email=email)
             username = User.objects.filter(username=username)
             if not email_list and not username:
                 user = serializer.save()
                 profile = Profile(user=user,
                                   bio='',
                                   photo_url='',
                                   location='',
                                   phone_number='')
                 profile.save()
                 data['response'] = 'Successfully registered!'
                 return Response(data, status=status.HTTP_200_OK)
             else:
                 data[
                     'response'] = 'User with that email or username already exists.'
                 return Response(
                     data, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
     else:
         data = serializer.errors
     return Response(data, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
示例#3
0
    def get_all_tokens_sum():
        """Test all users funded tokens."""
        token_names = ['ETH', 'ETH', 'DAI']
        for name in token_names:
            Bounty.objects.create(
                title='foo',
                value_in_token=3,
                token_name=name,
                web3_created=datetime(2008, 10, 31, tzinfo=pytz.UTC),
                github_url=
                'https://github.com/gitcoinco/web/issues/305#issuecomment-999999999',
                token_address='0x0',
                issue_description='hello world',
                bounty_owner_github_username='******',
                is_open=True,
                expires_date=datetime(2008, 11, 30, tzinfo=pytz.UTC),
                idx_project_length=5,
                project_length='Months',
                bounty_type='Feature',
                experience_level='Intermediate',
                raw_data={},
                current_bounty=True,
                network='mainnet',
            )

        profile = Profile(
            handle='gitcoinco',
            data={'type': 'Organization'},
        )
        query = profile.to_dict()['sum_all_funded_tokens']
        assert query[0]['token_name'] == 'DAI'
        assert query[0]['value_in_token'] == 3

        assert query[1]['token_name'] == 'ETH'
        assert query[1]['value_in_token'] == 6
示例#4
0
    def test_release_bounty_to_public_is_successful():
        now = timezone.now()
        profile = Profile(
            handle='foo',
        )
        bounty = Bounty(
            title='ReleaseToPublicTrueTest',
            idx_status='reserved',
            is_open=True,
            web3_created=now,
            expires_date=now + timezone.timedelta(minutes=2),
            bounty_reserved_for_user=profile,
            reserved_for_user_from=now,
            reserved_for_user_expiration=now + timezone.timedelta(minutes=2),
            github_url='https://github.com/gitcoinco/web/issues/12345678',
            raw_data={}
        )

        assert bounty.bounty_reserved_for_user is not None
        assert bounty.reserved_for_user_from is not None
        assert bounty.reserved_for_user_expiration is not None

        assert release_bounty_to_the_public(bounty, False) is True

        assert bounty.bounty_reserved_for_user is None
        assert bounty.reserved_for_user_from is None
        assert bounty.reserved_for_user_expiration is None
示例#5
0
 def test_profile():
     """Test the dashboard Profile model."""
     bounty = Bounty.objects.create(
         github_url='https://github.com/gitcoinco/web/issues/305',
         web3_created=datetime.now(tz=pytz.UTC),
         expires_date=datetime.now(tz=pytz.UTC) + timedelta(days=1),
         is_open=True,
         raw_data={},
         current_bounty=True,
         bounty_owner_github_username='******',
         network='mainnet',
     )
     tip = Tip.objects.create(
         emails=['*****@*****.**'],
         github_url='https://github.com/gitcoinco/web/issues/305',
         expires_date=datetime.now(tz=pytz.UTC) + timedelta(days=1),
     )
     profile = Profile(
         handle='gitcoinco',
         data={'type': 'Organization'},
     )
     assert str(profile) == 'gitcoinco'
     assert profile.is_org is True
     assert profile.bounties.first() == bounty
     assert profile.tips.first() == tip
     assert profile.github_url == 'https://github.com/gitcoinco'
     assert profile.get_relative_url() == '/gitcoinco'
示例#6
0
def addcvdetail(request):
    id = request.user.id
    profile = None

    if request.method == 'POST':
        if profile:
            print("--------------")
        else:
            profile = Profile()
        cv = CV()
        cv.save()
        objectivelist = request.POST.getlist('objective[]')
        certilist = request.POST.getlist('certificate[]')
        recommendationlist = request.POST.getlist('rec[]')
        recomendbylist = request.POST.getlist('recby[]')
        titlelist = request.POST.getlist('title[]')
        professionlist = request.POST.getlist('prof[]')

        print("_________________________________")
        print(certilist)
        for i in range(len(certilist)):
            print(i)
            cer = ProfileCertificate(cert=certilist[i])
            cer.save()
            cv.certificate.add(cer)
            cv.save()

        for i in range(len(titlelist)):
            title = cvtitle(resumetitle=titlelist[i])
            title.save()
            cv.title.add(title)
            cv.save()

        for i in range(len(professionlist)):
            profe = ProfileProession(profession=professionlist[i])
            profe.save()
            cv.profession.add(profe)
            cv.save()

        for i in range(len(objectivelist)):
            objective = Profileinfo(info=objectivelist[i])
            objective.save()
            cv.profinfo.add(objective)
            cv.save()
        for i in range(len(recommendationlist)):
            recomend = Recommendations(recomend=recommendationlist[i],
                                       recomendby=recomendbylist[i])
            recomend.save()
            cv.recommend.add(recomend)
            cv.save()

        cv.user.add(request.user)

        cv.save()
        return generate(request, cv.id)
    return render(request, 'dashboard/resume_form.html', {
        'profile': profile,
        'id': id
    })
示例#7
0
 def test_interest(self):
     """Test the dashboard Interest model."""
     profile = Profile(
         handle='foo',
     )
     interest = Interest(
         profile=profile,
     )
     assert str(interest) == 'foo'
示例#8
0
 def test_interest():
     """Test the dashboard Interest model."""
     profile = Profile(
         handle='foo',
     )
     interest = Interest(
         profile=profile,
     )
     assert str(interest) == 'foo / pending: False / status: okay'
示例#9
0
 def save(self):
     profile = Profile(
         user=self.validated_data('user'),
         bio=self.validated_data('bio'),
         photo_url=self.validated_data('photo_url'),
         location=self.validated_data('location'),
         phone_number=self.validated_data('phone_number'),
     )
     profile.save()
示例#10
0
    def test_total_reserved_length_label_is_indefinite_when_no_expiration_set(
    ):
        dummy_profile = Profile(handle='foo')

        bounty = Bounty(
            title='ReservedLengthLabelTest',
            idx_status=0,
            is_open=True,
            web3_created=datetime(2008, 10, 31, tzinfo=pytz.UTC),
            expires_date=datetime(2008, 11, 30, tzinfo=pytz.UTC),
            github_url='https://github.com/gitcoinco/web/issues/12345678',
            bounty_reserved_for_user=dummy_profile,
            reserved_for_user_from=timezone.now(),
            raw_data={})

        assert bounty.total_reserved_length_label == 'indefinitely'
示例#11
0
def register(request):
    if request.method == 'POST':
        form = UserRegistrationForm(request.POST)
        if form.is_valid():
            userObj = form.cleaned_data
            username = userObj['username']
            email_address = userObj['email']
            password = userObj['password']
            User = get_user_model()
            if not (User.objects.filter(username=username).exists()
                    or User.objects.filter(email=email_address).exists()):
                User.objects.create_user(username, email_address, password)
                user = authenticate(username=username, password=password)
                auth_login(request, user)
                profile = Profile(user=User.objects.get(username=username),
                                  balance=0,
                                  email=email_address)
                temp_slug = uuid.uuid4().hex
                profile.verify_email_slug = temp_slug
                profile.save()

                send_mail(
                    'Please Verify your account',
                    'You have just signed up on SMMPanel.guru. Please confirm your Email ID by clicking on https://smmpanel.guru/verify-email/'
                    + temp_slug,
                    '*****@*****.**',
                    [email_address],
                    fail_silently=False,
                )

                send_mail(
                    'New sign up on SMMPanel.guru',
                    email_address +
                    ' just signed up on SMMPanel.guru. A moment of joy, more and more people are joining SMMPanel.guru.',
                    '*****@*****.**',
                    ['*****@*****.**'],
                    fail_silently=False,
                )

                return HttpResponseRedirect('/dashboard')
            else:
                messages.add_message(
                    request, messages.ERROR,
                    'Looks like a username with that email or password already exists.'
                )
                return HttpResponseRedirect('/')
    return HttpResponseRedirect('/')
示例#12
0
    def test_total_reserved_length_label_when_reservation_is_three_hours():
        dummy_profile = Profile(handle='foo')

        now = timezone.now()
        bounty = Bounty(
            title='ReservedLengthLabelTest',
            idx_status=0,
            is_open=True,
            web3_created=datetime(2008, 10, 31, tzinfo=pytz.UTC),
            expires_date=datetime(2008, 11, 30, tzinfo=pytz.UTC),
            github_url='https://github.com/gitcoinco/web/issues/12345678',
            bounty_reserved_for_user=dummy_profile,
            reserved_for_user_from=now,
            reserved_for_user_expiration=now + timezone.timedelta(hours=3),
            raw_data={})

        assert bounty.total_reserved_length_label == '3 hours'
示例#13
0
def create_profile(request):
    if request.method == 'POST':
        profile_create = Profile(
            username = User.objects.get(username=request.user.username),
            photo = request.FILES['photo'],
            nickname = request.POST['nickname'],
            telegram = request.POST['telegram'],
            skype = request.POST['skype'],
            hipchat = request.POST['hipchat'],
            phone = request.POST['phone'],
            about = request.POST['about'],
            agent = True,
        )
        profile_create.save()
        system_notify("Bem vindo a Valhalla!","/about", request)
        return redirect('/home', status=200)
    else:
        return HttpResponse('Unauthorized', status=401)
示例#14
0
def profile(request, email):
    # Create your views here.
    # If this is a POST request then process the Form data

    # user=Student.objects.filter(student_email__exact=email)
    profile = Profile()
    # jr=Joiners()
    if request.method == 'POST':

        # Create a form instance and populate it with data from the request (binding):
        form = ProfileForm(request.POST)

        # Check if the form is valid:
        if form.is_valid():
            # process the data in form.cleaned_data as required (here we just write it to the model due_back field)
            profile.test_uid = form.cleaned_data['test_uid']
            # jr.test_uid=profile.test_uid
            profile.test_score = 0
            profile.ques_used = 0
            # profile.ques_id=1
            profile.student_emailid = email
            # jr.save()
            profile.save()
            zero = 0
            zero = str(zero)
            # redirect to a new URL:
            return HttpResponseRedirect('/test/%s/%s/%s' %
                                        (email, profile.test_uid, zero))

    # If this is a GET (or any other method) create the default form.
    else:
        form = ProfileForm()

    context = {'form': form, 'email': email, 'Profile': profile}

    return render(request, 'dashboard.html', context)
示例#15
0
def exam(request, email, testno, qno):
    qno = int(qno)
    pr = list(
        Profile.objects.filter(test_uid__exact=testno,
                               student_emailid__exact=email,
                               ques_id__exact=qno))

    mcq = Mcq.objects.filter(test_no__exact=testno)
    total_ques = mcq.count()
    if request.method == 'POST':
        form = TestForm(request.POST)
        if form.is_valid():
            one = form.cleaned_data['ans1']
            two = form.cleaned_data['ans2']
            three = form.cleaned_data['ans3']
            four = form.cleaned_data['ans4']
            # jr=list(Joiners.objects.filter(test_uid__exact=testno,student_emailid__exact=email,ques_id__exact=qno))
            # if len(jr)==0:
            #     jrr=Joiners()
            #     jrr.ques_used=0
            #     jrr.student_emailid=email
            #     jrr.ques_id=qno
            #     jrr.test_uid=testno
            #     jrr.save()
            #     jr.append(jrr)

            if one == mcq[qno].ans1 and two == mcq[qno].ans2 and three == mcq[
                    qno].ans3 and four == mcq[qno].ans4 and pr[
                        0].ques_used == 0:
                # qno=str(qno)
                # qno=int(qno)
                pr[0].test_score = pr[0].test_score + mcq[qno].points
                pr[0].ques_used = 1
                # jr[0].save()
                # qno=str(qno)
                # request.session[qno]=True
                # request.session.modified=True
                pr[0].save()

            # pr[0].save()
            qno = int(qno)
            qno = qno + 1
            qno = str(qno)
            pro = Profile()
            pro.test_uid = testno
            pro.ques_used = 0
            pro.test_score = 0
            pro.ques_id = qno
            pro.student_emailid = email
            pro.save()
            return HttpResponseRedirect('/test/%s/%s/%s' %
                                        (email, testno, qno))
    else:
        form = TestForm()
    if qno < total_ques:
        context = {'form': form, 'Mcq': mcq[qno], 'Profile': pr[0]}
        return render(request, 'ques.html', context)
    else:
        pr = list(
            Profile.objects.filter(test_uid__exact=testno,
                                   student_emailid__exact=email))
        score = 0
        for i in pr:
            score += int(i.test_score)
        for i in range(len(pr)):
            pr[i].test_score = score
            pr[i].save()

        context = {
            'form': form,
            'Mcq': mcq[qno - 1],
            'Profile': pr[0],
            'score': score
        }
        return render(request, 'result.html', context)
示例#16
0
文件: views.py 项目: mdali157/cv2
def update_profile(request):
    id = request.user.id
    profile = Profile.objects.filter(user=request.user).first()
    print(profile)

    if request.method == 'POST':
        if profile:
            print("--------------")
        else:
            profile = Profile()
        firstname = request.POST.get("fname")
        fathername = request.POST.get("lname")
        aging = request.POST.get("age")
        sex = request.POST.get("gender")

        # education

        inslist = request.POST.getlist("Institute[]")
        boardlist = request.POST.getlist("Board_Uni[]")
        degreelist = request.POST.getlist("Degree[]")
        startingdatelist = request.POST.getlist("PassingYear[]")
        endingdatelist = request.POST.getlist("enddate[]")
        resultlist = request.POST.getlist("Result[]")
        percentagelist = request.POST.getlist("Number_CGPA[]")

        # Experience

        orglist = request.POST.getlist("Organization[]")
        pdlist = request.POST.getlist("Previous_Designation[]")
        fromdlist = request.POST.getlist("FromDate[]")
        todlist = request.POST.getlist("ToDate[]")
        reslist = request.POST.getlist("Responsibility[]")

        # skiils
        skilllist = request.POST.getlist('Skills[]')

        # contact
        mail = request.POST.get('email')
        number1 = request.POST.get('contact1')
        number2 = request.POST.get('contact2')
        linked = request.POST.get('linkedin')
        location = request.POST.get('address')

        profile.name = firstname
        profile.fname = fathername
        profile.age = aging
        profile.gender = sex

        profile.email = mail
        profile.contactno1 = number1
        profile.contactno2 = number2
        profile.linkedin = linked
        profile.address = location
        profile.save()
        profile.user.add(request.user)
        profile.save()

        # cont = ProfileContact(email=mail, contactno1=number1, contactno2=number2, linkedin=linked, address=location)
        # cont.save()
        # profile.contact.add(cont)
        # profile.save()

        profile.education.clear()
        # object = Employee.objects.all()
        for i in range(len(inslist)):
            print(i)

            edu = ProfileEducation(institute=inslist[i], board=boardlist[i], degree=degreelist[i],
                                   startingdate=startingdatelist[i], endingdate=endingdatelist[i],
                                   result=resultlist[i], percentage=percentagelist[i])
            edu.save()
            profile.education.add(edu)
            profile.save()

        profile.experience.clear()
        for i in range(len(orglist)):
            exp = ProfileExperience(organization=orglist[i], previousDesignation=pdlist[i], startingDate=fromdlist[i],
                                    endingDate=todlist[i], responsibilities=reslist[i])
            exp.save()
            profile.experience.add(exp)
            profile.save()

        profile.skills.clear()
        for i in range(len(skilllist)):
            skl = ProfileSkills(skills=skilllist[i])
            skl.save()
            profile.skills.add(skl)
            profile.save()
        #
        # detail = Profile.objects.filter(user=request.user).first()
        # return render(request, 'dashboard/profile_view.html', {'id': id, 'detail': detail})
        request.method = 'GET'
        return newProfile(request)
    return render(request, 'dashboard/profile_update.html', {'profile': profile, 'id': id})
示例#17
0
文件: views.py 项目: mdali157/cv2
def addcvdetail2(request):
    id = request.user.id
    profile = None

    if request.method == 'POST':
        if profile:
            print("--------------")
        else:
            profile = Profile()
        cv2 = CV2()
        cv2.save()
        title2list = request.POST.getlist('titelecv2[]')
        proslist = request.POST.getlist('profession[]')
        introlist = request.POST.getlist('Introduction[]')
        expertiselist = request.POST.getlist('Areaofexpertise[]')
        bookslist = request.POST.getlist('BooksAuthored[]')
        certificatelist = request.POST.getlist('certificatecv2[]')
        reflist = request.POST.getlist('ref[]')
        orglist = request.POST.getlist('org[]')
        emaillist = request.POST.getlist('email[]')
        awardlist = request.POST.getlist('awards[]')

        print("_________________________________")

        for i in range(len(title2list)):
            print(i)
            title2 = ProfileTitlecv2(titcv2=title2list[i])
            title2.save()
            cv2.titlecv2.add(title2)
            cv2.save()


        for i in range(len(awardlist)):
            print(i)
            award2 = ProfileAwardscv2(awcv2=awardlist[i])
            award2.save()
            cv2.awardscv2.add(award2)
            cv2.save()


        for i in range(len(reflist)):
            print(i)
            refference2 = ProfileReferencescv2(refcv2=reflist[i],orgcv2=orglist[i],emailcv2=emaillist[i])
            refference2.save()
            cv2.referencescv2.add(refference2)
            cv2.save()

        for i in range(len(certificatelist)):
            print(i)
            certificate2 = ProfileCertificatecv2(certcv2=certificatelist[i])
            certificate2.save()
            cv2.certificatecv2.add(certificate2)
            cv2.save()


        for i in range(len(bookslist)):
            print(i)
            book = ProfileBooksAuthoredcv2(bookscv2=bookslist[i])
            book.save()
            cv2.books_authored.add(book)
            cv2.save()

        for i in range(len(proslist)):
            print(i)
            prof = ProfileProfessioncv2(procv2=proslist[i])
            prof.save()
            cv2.professsioncv2.add(prof)
            cv2.save()

        for i in range(len(introlist)):
            intro = ProfileIntroductioncv2(introcv2=introlist[i])
            intro.save()
            cv2.introductioncv2.add(intro)
            cv2.save()

        for i in range(len(expertiselist)):
            expertise = ProfileAreaofexpertisecv2(areaofexpertisecv2=expertiselist[i])
            expertise.save()
            cv2.area_of_expertisecv2.add(expertise)
            cv2.save()

        cv2.user.add(request.user)
        cv2.save()
        return generateCV2(request, cv2.id)
    return render(request, 'dashboard/resume_form2.html', {'profile': profile, 'id': id})