当前位置: 首页>>代码示例>>Python>>正文


Python Job.save方法代码示例

本文整理汇总了Python中job.models.Job.save方法的典型用法代码示例。如果您正苦于以下问题:Python Job.save方法的具体用法?Python Job.save怎么用?Python Job.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在job.models.Job的用法示例。


在下文中一共展示了Job.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create

# 需要导入模块: from job.models import Job [as 别名]
# 或者: from job.models.Job import save [as 别名]
def create(request, project_id):
    project = get_object_or_404(
        Project,
        id=project_id,
        is_active=True,
        author=request.user
    )
    if request.method == 'POST':
        form = JobForm(request.POST)
        if form.is_valid():
            job = Job(
                project=project,
                title=form.cleaned_data['title'],
                area=form.cleaned_data['area'],
                description=form.cleaned_data['description']
            )
            job.save()
            return redirect(
                request,
                'project-read',
                [project.id],
                {request.url_name: 'True'}
            )
    else:
        form = JobForm()
    params = {'project': project, 'form': form}
    params.update(csrf(request))
    return response(request, params)
开发者ID:rodrigoalveslima,项目名称:runn,代码行数:30,代码来源:views.py

示例2: test_get_shift_slots_remaining

# 需要导入模块: from job.models import Job [as 别名]
# 或者: from job.models.Job import save [as 别名]
    def test_get_shift_slots_remaining(self):
        """ Test get_shift_slots_remaining(s_id) """

        e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")

        e1.save()

        j1 = Job(
            name="Software Developer",
            start_date="2012-10-22",
            end_date="2012-10-23",
            description="A software job",
            event=e1,
        )

        j1.save()

        s1 = Shift(date="2012-12-10", start_time="9:00", end_time="3:00", max_volunteers=1, job=j1)

        s2 = Shift(date="2012-6-25", start_time="10:00", end_time="4:00", max_volunteers=2, job=j1)

        s3 = Shift(date="2012-1-9", start_time="12:00", end_time="6:00", max_volunteers=4, job=j1)

        s1.save()
        s2.save()
        s3.save()

        self.assertIsNotNone(get_shift_slots_remaining(s1.id))
        self.assertIsNotNone(get_shift_slots_remaining(s2.id))
        self.assertIsNotNone(get_shift_slots_remaining(s3.id))
开发者ID:ahmedsabie,项目名称:vms,代码行数:32,代码来源:tests.py

示例3: test_increment_slots_remaining

# 需要导入模块: from job.models import Job [as 别名]
# 或者: from job.models.Job import save [as 别名]
    def test_increment_slots_remaining(self):

        j1 = Job(job_title = "Software Developer",
                start_date = "2012-10-22",
                end_date = "2012-10-23",
                description = "A software job")

        j1.save()

        s1 = Shift(date = "2012-10-23",
                    location = "Google Drive",
                    start_time = "9:00",
                    end_time = "3:00",
                    max_volunteers = 1,
                    slots_remaining = 0,
                    job = j1)

        s1.save()

        self.assertEqual(s1.slots_remaining, 0)
        increment_slots_remaining(s1)

        self.assertEqual(s1.slots_remaining, 1)
        increment_slots_remaining(s1)

        self.assertEqual(s1.slots_remaining, 2)
        increment_slots_remaining(s1)

        self.assertEqual(s1.slots_remaining, 3)
        increment_slots_remaining(s1)

        self.assertEqual(s1.slots_remaining, 4)
开发者ID:yaseppochi,项目名称:vms,代码行数:34,代码来源:tests.py

示例4: test_get_event_by_shift_id

# 需要导入模块: from job.models import Job [as 别名]
# 或者: from job.models.Job import save [as 别名]
    def test_get_event_by_shift_id(self):
        e1 = Event(
                name="Open Source Event",
                start_date="2012-10-22",
                end_date="2012-10-23"
                )

        e1.save()

        j1 = Job(
                name="Software Developer",
                start_date="2012-10-22",
                end_date="2012-10-23",
                description="A software job",
                event=e1
                )

        j2 = Job(
                name="Systems Administrator",
                start_date="2012-9-1",
                end_date="2012-10-26",
                description="A systems administrator job",
                event=e1
                )

        j1.save()
        j2.save()

        s1 = Shift(
                date="2012-10-23",
                start_time="9:00",
                end_time="3:00",
                max_volunteers=1,
                job=j1
                )

        s2 = Shift(
                date="2012-10-23",
                start_time="10:00",
                end_time="4:00",
                max_volunteers=2,
                job=j1
                )

        s3 = Shift(
                date="2012-10-23",
                start_time="12:00",
                end_time="6:00",
                max_volunteers=4,
                job=j2
                )

        s1.save()
        s2.save()
        s3.save()
        
        self.assertIsNotNone(get_event_by_shift_id(s1.id))
        self.assertIsNotNone(get_event_by_shift_id(s2.id))
        self.assertIsNotNone(get_event_by_shift_id(s3.id))
开发者ID:ahmedsabie,项目名称:vms,代码行数:61,代码来源:tests.py

示例5: test_get_shifts_with_open_slots

# 需要导入模块: from job.models import Job [as 别名]
# 或者: from job.models.Job import save [as 别名]
    def test_get_shifts_with_open_slots(self):
        """ Test get_shifts_with_open_slots(j_id) """
        u1 = User.objects.create_user("Yoshi")

        v1 = Volunteer(
            first_name="Yoshi",
            last_name="Turtle",
            address="Mario Land",
            city="Nintendo Land",
            state="Nintendo State",
            country="Nintendo Nation",
            phone_number="2374983247",
            email="[email protected]",
            user=u1,
        )

        v1.save()

        e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")

        e1.save()

        j1 = Job(
            name="Software Developer",
            start_date="2012-10-22",
            end_date="2012-10-23",
            description="A software job",
            event=e1,
        )

        j2 = Job(
            name="Systems Administrator",
            start_date="2012-9-1",
            end_date="2012-10-26",
            description="A systems administrator job",
            event=e1,
        )

        j1.save()
        j2.save()

        s1 = Shift(date="2012-10-23", start_time="9:00", end_time="3:00", max_volunteers=1, job=j1)

        s2 = Shift(date="2012-10-23", start_time="10:00", end_time="4:00", max_volunteers=2, job=j1)

        s3 = Shift(date="2012-10-23", start_time="12:00", end_time="6:00", max_volunteers=4, job=j2)

        s1.save()
        s2.save()
        s3.save()

        self.assertIsNotNone(get_shifts_with_open_slots(j1.id))
        self.assertIsNotNone(get_shifts_with_open_slots(j2.id))
开发者ID:ahmedsabie,项目名称:vms,代码行数:55,代码来源:tests.py

示例6: run

# 需要导入模块: from job.models import Job [as 别名]
# 或者: from job.models.Job import save [as 别名]
    def run(self):
        counter = 0
        for job in self.jobs:
            new_job = Job(
                title=job.title,
                description=job.description,
                employer=self.profile,
                availability=job.availability,
                experience=job.experience,
                education=job.education,
                employment_type=job.employment_type,
                overtime=job.overtime,
                latitude=job.latitude,
                longitude=job.longitude,
            )
            new_job.save()
            new_job.workday = job.workday.all()
            new_job.industry = job.industry.all()
            new_job.save()

            new_location = JobLocation(
                business_name=job.location.business_name,
                business_address1=job.location.business_address1,
                business_address2=job.location.business_address2,
                city=job.location.city,
                zip_code=job.location.zip_code,
                latitude=job.location.latitude,
                longitude=job.location.longitude,
                job=new_job,
            )
            new_location.save()

            for existing_profile in self.profiles:
                rec = JobRecommendation(
                    job=new_job,
                    applicant=existing_profile,
                    state=(JobRecommendation.NEW_REC_SENT if counter > 2 else JobRecommendation.APPLIED_REC),
                )
                rec.save()

                if counter <= 2:
                    application = ApplicantJob(job=new_job, applicant=existing_profile, send_email=False)
                    application.save()

                if existing_profile.id == 24 and job.id == 12:
                    application = ApplicantJob(job=new_job, applicant=existing_profile, send_email=False)
                    application.save()

                counter = counter + 1

            counter = 0
开发者ID:codeforoakland,项目名称:txt2wrk,代码行数:53,代码来源:backends.py

示例7: get_shifts_ordered_by_date

# 需要导入模块: from job.models import Job [as 别名]
# 或者: from job.models.Job import save [as 别名]
    def get_shifts_ordered_by_date(self):

        e1 = Event(name = "Open Source Event",
                start_date = "2012-10-22",
                end_date = "2012-10-23")

        e1.save()

        j1 = Job(name = "Software Developer",
            start_date = "2012-10-22",
            end_date = "2012-10-23",
            description = "A software job",
            event = e1)

        j1.save()

        s1 = Shift(date = "2012-1-10",
            start_time = "9:00",
            end_time = "3:00",
            max_volunteers = 1,
            job = j1)

        s2 = Shift(date = "2012-6-25",
            start_time = "10:00",
            end_time = "4:00",
            max_volunteers = 2,
            job = j1)

        s3 = Shift(date = "2012-12-9",
            start_time = "12:00",
            end_time = "6:00",
            max_volunteers = 4,
            job = j1)

        s1.save()
        s2.save()
        s3.save()

        #test typical case
        shift_list = get_shifts_ordered_by_date(j1.id)
        self.assertIsNotNone(shift_list)
        self.assertNotEqual(shift_list, False)
        self.assertEqual(len(shift_list), 3)
        self.assertIn(s1, shift_list)
        self.assertIn(s2, shift_list)
        self.assertIn(s3, shift_list)

        #test order
        self.assertEqual(shift_list[0].date, s1.date)
        self.assertEqual(shift_list[1].date, s2.date)
        self.assertEqual(shift_list[2].date, s3.date)
开发者ID:Ads7,项目名称:vms,代码行数:53,代码来源:test_unit.py

示例8: test_get_shift_by_id

# 需要导入模块: from job.models import Job [as 别名]
# 或者: from job.models.Job import save [as 别名]
    def test_get_shift_by_id(self):

        e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")

        e1.save()

        j1 = Job(
            name="Software Developer",
            start_date="2012-10-22",
            end_date="2012-10-23",
            description="A software job",
            event=e1,
        )

        j1.save()

        s1 = Shift(date="2012-10-23", start_time="9:00", end_time="3:00", max_volunteers=1, job=j1)

        s2 = Shift(date="2012-10-23", start_time="10:00", end_time="4:00", max_volunteers=2, job=j1)

        s3 = Shift(date="2012-10-23", start_time="12:00", end_time="6:00", max_volunteers=4, job=j1)

        s1.save()
        s2.save()
        s3.save()

        # test typical cases
        self.assertIsNotNone(get_shift_by_id(s1.id))
        self.assertIsNotNone(get_shift_by_id(s2.id))
        self.assertIsNotNone(get_shift_by_id(s3.id))

        self.assertEqual(get_shift_by_id(s1.id), s1)
        self.assertEqual(get_shift_by_id(s2.id), s2)
        self.assertEqual(get_shift_by_id(s3.id), s3)

        # test non-existant cases
        self.assertIsNone(get_shift_by_id(100))
        self.assertIsNone(get_shift_by_id(200))
        self.assertIsNone(get_shift_by_id(300))
        self.assertIsNone(get_shift_by_id(400))

        self.assertNotEqual(get_shift_by_id(100), s1)
        self.assertNotEqual(get_shift_by_id(100), s2)
        self.assertNotEqual(get_shift_by_id(100), s3)
        self.assertNotEqual(get_shift_by_id(200), s1)
        self.assertNotEqual(get_shift_by_id(200), s2)
        self.assertNotEqual(get_shift_by_id(200), s3)
        self.assertNotEqual(get_shift_by_id(300), s1)
        self.assertNotEqual(get_shift_by_id(300), s2)
        self.assertNotEqual(get_shift_by_id(300), s3)
开发者ID:ahmedsabie,项目名称:vms,代码行数:52,代码来源:tests.py

示例9: get_shifts_by_date

# 需要导入模块: from job.models import Job [as 别名]
# 或者: from job.models.Job import save [as 别名]
    def get_shifts_by_date(self):

        j1 = Job(job_title = "Software Developer",
                start_date = "2012-10-22",
                end_date = "2012-10-23",
                description = "A software job")
        
        j1.save()

        s1 = Shift(date = "2012-1-10",
                    location = "Google Drive",
                    start_time = "9:00",
                    end_time = "3:00",
                    max_volunteers = 1,
                    slots_remaining = 1,
                    job = j1)

        s2 = Shift(date = "2012-6-25",
                    location = "Infinite Loop",
                    start_time = "10:00",
                    end_time = "4:00",
                    max_volunteers = 2,
                    slots_remaining = 2,
                    job = j1)

        s3 = Shift(date = "2012-12-9",
                    location = "Loopy Loop Road",
                    start_time = "12:00",
                    end_time = "6:00",
                    max_volunteers = 4,
                    slots_remaining = 4,
                    job = j1)

        s1.save()
        s2.save()
        s3.save()

        #test typical case
        shift_list = get_shifts_by_date(j1.id)
        self.assertIsNotNone(shift_list)
        self.assertNotEqual(shift_list, False)
        self.assertEqual(len(shift_list), 3)
        self.assertIn(s1, shift_list)
        self.assertIn(s2, shift_list)
        self.assertIn(s3, shift_list)

        #test order
        self.assertEqual(shift_list[0].date, s1.date)
        self.assertEqual(shift_list[1].date, s2.date)
        self.assertEqual(shift_list[2].date, s3.date)
开发者ID:yaseppochi,项目名称:vms,代码行数:52,代码来源:tests.py

示例10: create_job_with_details

# 需要导入模块: from job.models import Job [as 别名]
# 或者: from job.models.Job import save [as 别名]
def create_job_with_details(job):
    """
    Creates and returns job with passed name and dates
    """

    j1 = Job(
        name=job[0],
        start_date=job[1],
        end_date=job[2],
        description=job[3],
        event=job[4])

    j1.save()
    return j1
开发者ID:systers,项目名称:vms,代码行数:16,代码来源:utils.py

示例11: ReadTest

# 需要导入模块: from job.models import Job [as 别名]
# 或者: from job.models.Job import save [as 别名]
class ReadTest(TestCase):
    def setUp(self):
        self.client = Client()
        self.username = '[email protected]'
        self.email = '[email protected]'
        self.passwd = 'passwd'
        self.title = 'Test'
        self.area = 'DESIGN'
        self.description = 'Testing...'
        user = User.objects.create_user(self.username, self.email, self.passwd)
        self.project = Project(author=user)
        self.project.save()
        self.job = Job(project=self.project, title=self.title, area=self.area,
                       description=self.description)
        self.job.save()
        self.client.login(username=self.username, password=self.passwd)

    def test_login_required(self):
        self.client.logout()
        response = self.client.get(READ_URL % self.job.id)
        self.assertRedirects(response, LOGIN_URL + '?next=' + READ_URL % self.job.id)

    def test_get(self):
        response = self.client.get(READ_URL % self.job.id)
        self.assertEqual(response.status_code, 200)

    def test_invalid_id(self):
        response = self.client.get(READ_URL % '2')
        self.assertEqual(response.status_code, 404)

    def test_deactivated_project(self):
        self.project.is_active = False
        self.project.save()
        response = self.client.get(READ_URL % self.job.id)
        self.assertEqual(response.status_code, 404)

    def test_deactivated_project_author(self):
        username = '[email protected]'
        email = '[email protected]'
        passwd = 'abc'
        user = User.objects.create_user(username, email, passwd)
        self.client.logout()
        self.client.login(username=username, password=passwd)
        self.project.author.is_active = False
        self.project.author.save()
        response = self.client.get(READ_URL % self.job.id)
        self.assertEqual(response.status_code, 404)
开发者ID:rodrigoalveslima,项目名称:runn,代码行数:49,代码来源:tests.py

示例12: test_delete_shift

# 需要导入模块: from job.models import Job [as 别名]
# 或者: from job.models.Job import save [as 别名]
    def test_delete_shift(self):
        """ Test delete_shift(shift_id) """
        u1 = User.objects.create_user("Yoshi")

        v1 = Volunteer(
            first_name="Yoshi",
            last_name="Turtle",
            address="Mario Land",
            city="Nintendo Land",
            state="Nintendo State",
            country="Nintendo Nation",
            phone_number="2374983247",
            email="[email protected]",
            user=u1,
        )

        v1.save()

        e1 = Event(name="Open Source Event", start_date="2012-10-22", end_date="2012-10-23")

        e1.save()

        j1 = Job(
            name="Software Developer",
            start_date="2012-10-22",
            end_date="2012-10-23",
            description="A software job",
            event=e1,
        )

        j1.save()

        s1 = Shift(date="2012-10-23", start_time="1:00", end_time="12:00", max_volunteers=1, job=j1)

        s2 = Shift(date="2011-11-11", start_time="11:00", end_time="12:00", max_volunteers=3, job=j1)

        s1.save()
        s2.save()

        self.assertTrue(delete_shift(s1.id))
        self.assertFalse(delete_shift(100))

        register(v1.id, s2.id)
        self.assertFalse(delete_shift(s2.id))
开发者ID:ahmedsabie,项目名称:vms,代码行数:46,代码来源:tests.py

示例13: test_get_jobs_ordered_by_title

# 需要导入模块: from job.models import Job [as 别名]
# 或者: from job.models.Job import save [as 别名]
    def test_get_jobs_ordered_by_title(self):

        j1 = Job(job_title = "Software Developer",
                start_date = "2012-10-22",
                end_date = "2012-10-23",
                description = "A software job")

        j2 = Job(job_title = "Systems Administrator",
                start_date = "2012-9-1",
                end_date = "2012-10-26",
                description = "A systems administrator job")

        j3 = Job(job_title = "Project Manager",
                start_date = "2012-1-2",
                end_date = "2012-2-2",
                description = "A management job")

        j1.save()
        j2.save()
        j3.save()       
                    
        #test typical case
        job_list = get_jobs_ordered_by_title()
        self.assertIsNotNone(job_list)
        self.assertNotEqual(job_list, False)
        self.assertEqual(len(job_list), 3)
        self.assertIn(j1, job_list)
        self.assertIn(j2, job_list)
        self.assertIn(j3, job_list)

        #test order
        self.assertEqual(job_list[0].job_title, j3.job_title)
        self.assertEqual(job_list[1].job_title, j1.job_title)
        self.assertEqual(job_list[2].job_title, j2.job_title)
开发者ID:Nerdylicious,项目名称:vms-pre-integration,代码行数:36,代码来源:tests.py

示例14: test_get_job_by_id

# 需要导入模块: from job.models import Job [as 别名]
# 或者: from job.models.Job import save [as 别名]
    def test_get_job_by_id(self):

        e1 = Event(name = "Software Conference",
                start_date = "2012-10-22",
                end_date = "2012-10-25")

        e1.save()

        j1 = Job(name = "Software Developer",
                start_date = "2012-10-22",
                end_date = "2012-10-23",
                description = "A software job",
                event = e1)

        j2 = Job(name = "Systems Administrator",
                start_date = "2012-9-1",
                end_date = "2012-10-26",
                description = "A systems administrator job",
                event = e1)

        j3 = Job(name = "Project Manager",
                start_date = "2012-1-2",
                end_date = "2012-2-2",
                description = "A management job",
                event = e1)

        j1.save()
        j2.save()
        j3.save()

        #test typical cases
        self.assertIsNotNone(get_job_by_id(j1.id))
        self.assertIsNotNone(get_job_by_id(j2.id))
        self.assertIsNotNone(get_job_by_id(j3.id))

        self.assertEqual(get_job_by_id(j1.id), j1)
        self.assertEqual(get_job_by_id(j2.id), j2)
        self.assertEqual(get_job_by_id(j3.id), j3)

        #test non-existant cases
        self.assertIsNone(get_job_by_id(100))
        self.assertIsNone(get_job_by_id(200))
        self.assertIsNone(get_job_by_id(300))
        self.assertIsNone(get_job_by_id(400))

        self.assertNotEqual(get_job_by_id(100), j1)
        self.assertNotEqual(get_job_by_id(100), j2)
        self.assertNotEqual(get_job_by_id(100), j3)
        self.assertNotEqual(get_job_by_id(200), j1)
        self.assertNotEqual(get_job_by_id(200), j2)
        self.assertNotEqual(get_job_by_id(200), j3)
        self.assertNotEqual(get_job_by_id(300), j1)
        self.assertNotEqual(get_job_by_id(300), j2)
        self.assertNotEqual(get_job_by_id(300), j3)
开发者ID:Ads7,项目名称:vms,代码行数:56,代码来源:tests.py

示例15: test_get_jobs_by_event_id

# 需要导入模块: from job.models import Job [as 别名]
# 或者: from job.models.Job import save [as 别名]
    def test_get_jobs_by_event_id(self):
        """ Test get_jobs_by_event_id(e_id) """

        e1 = Event(
                name="Software Conference",
                start_date="2012-10-22",
                end_date="2012-10-25"
                )

        e1.save()

        j1 = Job(
                name="Software Developer",
                start_date="2012-10-22",
                end_date="2012-10-23",
                description="A software job",
                event=e1
                )

        j2 = Job(
                name="Systems Administrator",
                start_date="2012-9-1",
                end_date="2012-10-26",
                description="A systems administrator job",
                event=e1
                )

        j3 = Job(
                name="Project Manager",
                start_date="2012-1-2",
                end_date="2012-2-2",
                description="A management job",
                event=e1
                )

        j1.save()
        j2.save()
        j3.save()

        # test typical case
        job_list = get_jobs_by_event_id(e1.id)
        self.assertIsNotNone(job_list)
        self.assertNotEqual(job_list, False)
        self.assertEqual(len(job_list), 3)
        self.assertIn(j1, job_list)
        self.assertIn(j2, job_list)
        self.assertIn(j3, job_list)
开发者ID:ahmedsabie,项目名称:vms,代码行数:49,代码来源:tests.py


注:本文中的job.models.Job.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。