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


Python Issue.save方法代码示例

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


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

示例1: test_create_proposal

# 需要导入模块: from issues.models import Issue [as 别名]
# 或者: from issues.models.Issue import save [as 别名]
    def test_create_proposal(self):
        i = Issue(community=self.community, title="Issue ABC",
                  created_by=self.chairmen[0])
        i.full_clean()
        i.save()

        title = 'Proposal XYZ'
        content = 'hellow world'

        self.assertEquals(0, Proposal.objects.count())

        self.login_chairmen()
        url = reverse('proposal_create', args=(self.community.id, i.id))
        response = self.client.get(url)
        self.assertEquals(200, response.status_code)
        response = self.client.post(url, {
            'proposal-type': ProposalType.RULE,
            'proposal-title': title,
            'proposal-content': content,
            'proposal-tags': 'tag1,tag2,tag3',
        })
        self.assertEquals(200, response.status_code)
        # Ajax call returns a partial html
        self.assertEquals(1, Proposal.objects.count())
        p = Proposal.objects.all()[0]
        assert isinstance(p, Proposal)
        self.assertContains(response, p.get_absolute_url())
        self.assertEquals(title, p.title)
        self.assertEquals(content, p.content)
开发者ID:VehpuS,项目名称:OpenCommunity,代码行数:31,代码来源:issue_ui_test.py

示例2: create

# 需要导入模块: from issues.models import Issue [as 别名]
# 或者: from issues.models.Issue import save [as 别名]
def create(request):
    if request.method == 'POST':
        try:
            name = request.POST['name']
            description = request.POST['description']
            lat = request.POST['latitude']
            lng = request.POST['longitude']

        except:
            raise Http404

        issue = Issue()
        issue.name = name
        issue.description = description

        logging.debug('Debug latitude')

        issue.latitude = lat
        issue.longitude= lng

        issue.save()
        try:
            logging.debug('Saving issue')
            issue.save()

            # send email
            issue.new_issue_email()
        except:
            raise Http404

        return render(request, 'issues/show.html', {'issue': issue})
开发者ID:leonardok,项目名称:conserte.me,代码行数:33,代码来源:views.py

示例3: testIssueNotification

# 需要导入模块: from issues.models import Issue [as 别名]
# 或者: from issues.models.Issue import save [as 别名]
 def testIssueNotification(self):
     user = create_user()
 
     issue = Issue()
     issue.description = "This is a test"
     issue.save()
     
     assert Issue.all().count() == 1
开发者ID:andymckay,项目名称:arecibo,代码行数:10,代码来源:tests.py

示例4: test_vote_proposal

# 需要导入模块: from issues.models import Issue [as 别名]
# 或者: from issues.models.Issue import save [as 别名]
    def test_vote_proposal(self):
#        p = self.test_create_proposal()
        ######################################
        i = Issue(community=self.community, title="Issue ABC",
            created_by=self.chairmen[0])
        i.full_clean()
        i.save()
        title = 'Proposal XYZ'
        content = 'hellow world'
        p = Proposal.objects.create(type=ProposalType.RULE, issue=i, created_by=self.chairmen[0], title=title, content=content)
        ######################################
        #TODO: create this via HTML request
        pv = ProposalVote(proposal=p, user=self.members[0], value=ProposalVoteValue.CON)
        pv.full_clean()
        pv.save()
        return pv
开发者ID:Amannor,项目名称:OpenCommunity,代码行数:18,代码来源:issue_ui_test.py

示例5: handle

# 需要导入模块: from issues.models import Issue [as 别名]
# 或者: from issues.models.Issue import save [as 别名]
    def handle(self, count, service, min_lat=None, max_lat=None, min_lon=None, max_lon=None, **options):
        service = Service.objects.get(service_code=service)
        for i in range(count):
            lat = long = None
            if min_lat and max_lat and min_lon and max_lon:
                lat = random.uniform(min_lat, max_lat)
                long = random.uniform(min_lon, max_lon)

            issue = Issue(
                service=service,
                lat=lat,
                long=long,
                submitter_email='[email protected]',
                description=generate_description(),
            )
            issue.save()
        self.stdout.write('{} issues created'.format(count))
开发者ID:6aika,项目名称:issue-reporting,代码行数:19,代码来源:cfh_generate_random_issues.py

示例6: test_get_or_create_anonymously

# 需要导入模块: from issues.models import Issue [as 别名]
# 或者: from issues.models.Issue import save [as 别名]
    def test_get_or_create_anonymously(self):
        client = self.client

        # get get_or_create page
        response = client.get(reverse('issues.views.get_or_create',
                                      kwargs={'task_id': self.task.id, 'student_id': self.student.id}))
        self.assertEqual(response.status_code, 302, "Need login for get_or_create")

        issue = Issue()
        issue.student = self.student
        issue.task = self.task
        issue.save()

        # get issue_page page
        response = client.get(reverse('issues.views.issue_page',
                                      kwargs={'issue_id': issue.id}))
        self.assertEqual(response.status_code, 302, "Need login for issue_page")
开发者ID:znick,项目名称:anytask,代码行数:19,代码来源:tests.py

示例7: resource_report

# 需要导入模块: from issues.models import Issue [as 别名]
# 或者: from issues.models.Issue import save [as 别名]
def resource_report(request, object_id, template_name='depot/resource_report.html'):
    """
    View for reporting a report when a user finds a problem with it.
    """
    resource = get_one_or_404(Resource, id=ObjectId(object_id))
    reporter=get_account(request.user.id)

    # if 'next' in request.GET:
    #     url = request.GET['next']
    # else:
    #     url = None
    # url = url or reverse('resource', args=[resource.id])

    if Issue.objects(reporter=reporter, related_document=resource).count():
        messages.warning(request, 'You have already reported this resource.')
        return HttpResponseRedirect(reverse('resource', args=[resource.id]))

    if request.method == 'POST':
        form = ResourceReportForm(request.POST)
        if form.is_valid():

            severity=int(form.cleaned_data['severity'])
            message=form.cleaned_data['message']

            issue = Issue(
                message=message,
                severity=severity,
                reporter=reporter)
            issue.related_document = resource
            issue.save()
            issue.notify_created()
            
            # only moderate as STATUS_BAD if SEVERITY_CRITICAL
            if severity == SEVERITY_CRITICAL:
                resource.moderate_as_bad(reporter)

            return HttpResponseRedirect(reverse('issue_detail', args=[issue.id]))
    else:
        form = ResourceReportForm()

    return render_to_response(template_name, {
        'next': urlquote_plus(request.GET.get('next', '')),
        'form': form,
        'object': resource,
    }, RequestContext(request))
开发者ID:majailievska,项目名称:engineclub,代码行数:47,代码来源:views.py

示例8: testIssueAndErrorNotification

# 需要导入模块: from issues.models import Issue [as 别名]
# 或者: from issues.models.Issue import save [as 别名]
    def testIssueAndErrorNotification(self):
        user = create_user()
        
        issue = Issue()
        issue.description = "This is a test"
        issue.save()
        
        assert Issue.all().count() == 1

        c = Client()
        c.post(reverse("error-post"), test_data)

        #assert Notification.all().count() == 2
        # this would be 2 when issues are turned on
        assert Notification.all().count() == 1
        
        c = Client()
        res = c.get(reverse("notification-send"))        
        self.assertEquals(len(mail.outbox), 1)
开发者ID:andymckay,项目名称:arecibo,代码行数:21,代码来源:tests.py

示例9: test_issue_create_filled

# 需要导入模块: from issues.models import Issue [as 别名]
# 或者: from issues.models.Issue import save [as 别名]
    def test_issue_create_filled(self):
        year = Year.objects.create(start_year=2016)
        group = Group.objects.create(name='name_groups', year=year)
        course = Course.objects.create(name='course_name',
                                       year=year)
        course.groups = [group]
        course.save()
        task = Task.objects.create(title='task',
                                   course=course)
        student = User.objects.create_user(username='student',
                                           password='password')
        responsible = User.objects.create_user(username='responsible',
                                               password='password')
        followers = [User.objects.create_user(username='follower1',
                                              password='password')]

        status = IssueStatus.objects.get(name=u'{"ru": "Зачтено", "en": "Accepted"}')

        issue = Issue()
        issue.student = student
        issue.task = task
        issue.mark = 3
        issue.responsible = responsible
        issue.status_field = status
        issue.save()
        issue.followers = followers
        issue.save()
        issue_id = issue.id

        issue = Issue.objects.get(id=issue_id)

        self.assertIsInstance(issue, Issue)
        self.assertEqual(issue.student, student)
        self.assertEqual(issue.task, task)
        self.assertEqual(issue.mark, 3)
        self.assertEqual(issue.responsible, responsible)
        self.assertEqual(issue.status_field, status)
        self.assertItemsEqual(issue.followers.all(), followers)
开发者ID:znick,项目名称:anytask,代码行数:40,代码来源:tests.py

示例10: setUp

# 需要导入模块: from issues.models import Issue [as 别名]
# 或者: from issues.models.Issue import save [as 别名]
    def setUp(self):
        u = SandstormUser(sid="xxxdummyxxx", name="Dummy User", handle="dummy")
        u.save()

        i1 = Issue(title="Foo", description="describe Foo", creator=u, deadline=date.today())
        i1.save()
        i2 = Issue(title="Bar", description="describe Bar", for_anon=True, creator=u, deadline=date.today() + timedelta(days=2))
        i2.save()
        i3 = Issue(title="Baz", description="describe Baz", subscriber_only=True, creator=u)
        i3.save()

        c1_1 = Comment(body="Hohoho", issue=i1, creator=u)
        c1_1.save()
        c2_1 = Comment(body="Funny!", issue=i1, creator=u)
        c2_1.save()
开发者ID:qznc,项目名称:family_issue_tracker,代码行数:17,代码来源:tests.py

示例11: testIssueNumber

# 需要导入模块: from issues.models import Issue [as 别名]
# 或者: from issues.models.Issue import save [as 别名]
    def testIssueNumber(self):
        issue = Issue()
        issue.description = "This is a test"
        issue.save()
        assert issue.number == 1

        issue = Issue()
        issue.description = "This is a test"
        issue.save()
        assert issue.number == 2

        old_issue = issue

        issue = Issue()
        issue.description = "This is a test"
        issue.save()
        assert issue.number == 3, issue.number

        old_issue.delete()

        issue = Issue()
        issue.description = "This is a test"
        issue.save()
        assert issue.number == 4
开发者ID:pombredanne,项目名称:arecibo,代码行数:26,代码来源:tests.py

示例12: AnyContestTest

# 需要导入模块: from issues.models import Issue [as 别名]
# 或者: from issues.models.Issue import save [as 别名]
class AnyContestTest(TestCase):
    @classmethod
    def setUpClass(cls):
        cls.contest = ContestServerMock()
        cls.contest.start()
        time.sleep(0.5)

        cls.contest_port = cls.contest.httpd.server_address[1]

    @classmethod
    def tearDownClass(cls):
        cls.contest.stop()

    def setUp(self):
        self.year = Year.objects.create(start_year=2016)
        self.group = Group.objects.create(name='name_groups', year=self.year)
        self.course = Course.objects.create(name='course_name',
                                            year=self.year)
        self.course.groups = [self.group]
        self.course.save()

        self.task = Task.objects.create(title='task',
                                        course=self.course,
                                        problem_id="A")
        self.student = User.objects.create_user(username='student',
                                                password='password')
        self.responsible = User.objects.create_user(username='responsible',
                                                    password='password')

        status = IssueStatus.objects.get(tag=Issue.STATUS_ACCEPTED)

        self.issue = Issue()
        self.issue.student = self.student
        self.issue.task = self.task
        self.issue.responsible = self.responsible
        self.issue.status_field = status
        self.issue.save()
        self.issue.save()
        self.issue_id = self.issue.id

    def test_contest_info(self):
        self.maxDiff = None
        # with override_settings(CONTEST_API_URL='http://127.0.0.1:{}/anytask/'.format(self.contest_port))
        self.assertDictEqual(get_contest_info(1, lang='ru')[1], tests_data.CONTEST_INFO['result'])

    def test_contest_submition_ok(self):
        contest_submition = ContestSubmission()
        contest_submition.issue = self.issue
        contest_submition.author = self.student

        event_create_file = Event.objects.create(issue=self.issue, field=IssueField.objects.get(name='file'))
        f = File.objects.create(file=SimpleUploadedFile('test_rb.py', b'print "hello world!"'), event=event_create_file)
        contest_submition.file = f

        contest_submition.save()

        self.assertTrue(contest_submition.upload_contest("py"))
        self.assertEquals(contest_submition.run_id, "1")

    def test_contest_submition_fail(self):
        contest_submition = ContestSubmission()
        contest_submition.issue = self.issue
        contest_submition.author = self.student

        event_create_file = Event.objects.create(issue=self.issue, field=IssueField.objects.get(name='file'))
        f = File.objects.create(file=SimpleUploadedFile('test_fail_rb.py', b'print "_failed_"'),
                                event=event_create_file)
        contest_submition.file = f

        contest_submition.save()

        self.assertFalse(contest_submition.upload_contest("py"))
        self.assertEquals(contest_submition.send_error, "Submit error in fake server!")

    def test_check_submission_ok(self):
        contest_submition = ContestSubmission()
        contest_submition.issue = self.issue
        contest_submition.author = self.student
        contest_submition.run_id = "1"

        event_create_file = Event.objects.create(issue=self.issue, field=IssueField.objects.get(name='file'))
        f = File.objects.create(file=SimpleUploadedFile('test_fail_rb.py', b'print "_failed_"'),
                                event=event_create_file)
        contest_submition.file = f

        contest_submition.save()

        comment = contest_submition.check_submission()
        self.assertIn(u'<p>{0}: ok</p>'.format(_(u'verdikt_jakontest')), comment)
        self.assertTrue(contest_submition.got_verdict)

    def test_check_submission_precompile_check_failed(self):
        contest_submition = ContestSubmission()
        contest_submition.issue = self.issue
        contest_submition.author = self.student
        contest_submition.run_id = "2"

        event_create_file = Event.objects.create(issue=self.issue, field=IssueField.objects.get(name='file'))
        f = File.objects.create(file=SimpleUploadedFile('test_fail_rb.py', b'print "_failed_"'),
                                event=event_create_file)
#.........这里部分代码省略.........
开发者ID:znick,项目名称:anytask,代码行数:103,代码来源:tests.py

示例13: Author

# 需要导入模块: from issues.models import Issue [as 别名]
# 或者: from issues.models.Issue import save [as 别名]
		usr = Author()
		usr_dict[user_id] = usr

	if (obj['meta_key'] == 'first_name'):
		usr.first_name = obj['meta_value']
		print usr

	if (obj['meta_key'] == 'last_name'):
		usr.last_name = obj['meta_value']

for k, v in usr_dict.items():
	v.save()


oldissue = Issue(volume = 109, issue = 1)
oldissue.save()

post_data=open('posteroo.json')

data = json.load(post_data)

post_dict = {}

for obj in data:
	if (obj['post_status'] != "publish"):
		continue;

	if (len(obj['post_content']) == 0) :
		continue;

	if (len(obj['post_title']) == 0) :
开发者ID:jeffbarg,项目名称:Horace-Mann-Record,代码行数:33,代码来源:scriptzydoo2.py

示例14: testLogAdded

# 需要导入模块: from issues.models import Issue [as 别名]
# 或者: from issues.models.Issue import save [as 别名]
    def testLogAdded(self):
        issue = Issue()
        issue.description = "This is a test"
        issue.save()

        assert issue.log_set[0]
开发者ID:alanjds,项目名称:arecibo,代码行数:8,代码来源:tests.py

示例15: ErrorTests

# 需要导入模块: from issues.models import Issue [as 别名]
# 或者: from issues.models.Issue import save [as 别名]
class ErrorTests(TestCase):
    # test the view for writing errors
    def setUp(self):
        for issue in Issue.all(): issue.delete()
        for log in Log.all(): log.delete()
        for comment in Comment.all(): comment.delete()
        for group in Group.all(): group.delete()
        for error in Error.all(): error.delete()
        for project in Project.all(): project.delete()

    def testLogAdded(self):
        issue = Issue()
        issue.description = "This is a test"
        issue.save()

        assert issue.log_set[0]

    def _setup(self):
        self.project = Project(name="testing")
        self.project.save()

        self.url = ProjectURL(url="http://test.areciboapp.com")
        self.url.project = self.project
        self.url.save()

        self.url = ProjectURL(url="http://www.areciboapp.com")
        self.url.project = self.project
        self.url.save()

        self.error = Error()
        for k, v in break_url("http://test.areciboapp.com/an/other").items():
            setattr(self.error, k, v)
        self.error.save()

    def _issue(self):
        self.issue = Issue()
        self.issue.description = "This is a test"
        self.issue.save()

    def testIssueGroup(self):
        self._setup()

        self._issue()

        group = Group.all()[0]
        self.issue.add_group(group)

        assert group == self.issue.issuegroup_set[0].group
        assert self.issue.issuegroup_set.count() == 1

        assert self.issue == IssueGroup.all().filter("issue = ", self.issue)[0].issue

    def testIssueURL(self):
        self._setup()

        self.issue = Issue()
        self.issue.description = "This is a test"
        self.issue.project = self.project
        self.issue.save()

        assert self.issue.issueprojecturl_set.count() == 2
        assert self.issue.issueprojecturl_set[0].status == "not_fixed"

    def testIssueURLFlexibility(self):
        self._setup()

        self._issue()
        assert self.issue == issue_by_number(self.issue.number)
        assert self.issue == issue_by_number(self.issue.number)

    def testIssueChanged(self):
        self.signal_fired = False
        def signal_fired(instance, old, **kw):
            self.signal_fired = True
        signals.issue_changed.connect(signal_fired, dispatch_uid="issue_changed")
        self._issue()
        self.issue.status = "rejected"
        self.issue.save()
        assert self.signal_fired

    def testIssuePriorityChanged(self):
        self.signal_fired = False
        def signal_fired(instance, old, new, **kw):
            self.signal_fired = True
            assert old in (None, 1)
            assert new in (1, 2)

        signals.issue_priority_changed.connect(signal_fired, dispatch_uid="issue_priority_changed")

        self._issue()
        self.issue.priority = 1
        self.issue.save()
        assert self.signal_fired

        self.signal_fired = False
        self.issue.priority = 2
        self.issue.save()
        assert self.signal_fired

    def testIssueStatusChanged(self):
#.........这里部分代码省略.........
开发者ID:alanjds,项目名称:arecibo,代码行数:103,代码来源:tests.py


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