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


Python Issue.save方法代码示例

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


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

示例1: save_issue

# 需要导入模块: from models import Issue [as 别名]
# 或者: from models.Issue import save [as 别名]
def save_issue(request):
    requester = models.Ti_user.objects.get(id=request.user.id)
    title = request.POST.get('title')
    description = request.POST.get('description')
    severity = request.POST.get('severity')
    department = models.Department.objects.get(department_name=request.POST.get('department'))
    issue = Issue(title = title, description = description, requester = requester, assigned_group = department, Severity = severity)
    issue.save()
    print issue.id
    comments = models.Comment.objects.filter(issue_id=issue.id).order_by('-created_time')
    return HttpResponseRedirect('/issue/%s' %issue.id)
开发者ID:sjhest,项目名称:Ti,代码行数:13,代码来源:views.py

示例2: test_issue_creation

# 需要导入模块: from models import Issue [as 别名]
# 或者: from models.Issue import save [as 别名]
    def test_issue_creation(self):
        c = Category.objects.all()[0]

        i = Issue(summary="Test",
                  description="Test",
                  reporter_name="User",
                  reporter_email="[email protected]",
                  urgent=True,
                  category=c)
        i.save()
        iid = i.id
        i = Issue.objects.get(id=iid)
        self.failUnlessEqual(i.summary, "Test")
开发者ID:lemonad,项目名称:tratten,代码行数:15,代码来源:tests.py

示例3: reconcile_db_with_gh

# 需要导入模块: from models import Issue [as 别名]
# 或者: from models.Issue import save [as 别名]
def reconcile_db_with_gh(*args, **kwargs):
    ghc = GitHubConnector()
    issues = ghc.get_all_issues()
    repos = ghc.get_all_repos()

    for repo in repos:
        r = Repo(github_id=repo.id, name=repo.name)
        r.save()

    for issue in issues:
        i = Issue(github_id=issue.id)
        i.title = issue.title
        i.number = issue.number
        i.repo = Repo.objects.get(name=issue.repository[1])
        i.save()

    print "Not only did your task run successfully, but you're damned good looking too."
开发者ID:wbrefvem,项目名称:worklog,代码行数:19,代码来源:tasks.py

示例4: add_issue_to_database

# 需要导入模块: from models import Issue [as 别名]
# 或者: from models.Issue import save [as 别名]
def add_issue_to_database(request):


    issue = request.session.get('issue', False)
    service = Service.objects.get(name=issue['service'])

    try:
        db_issue = Issue.objects.get(service=service, number=issue['number'], project=issue['project'])
        if db_issue.status == "paid":
            error = "I see that issue has been closed and paid already."
            messages.error(request, error)
            return False
    except:

        db_issue = Issue(
        service=service,
        number=issue['number'],
        project=issue['project'],
        user=issue.has_key('user') and issue['user'] or '',
        title=issue['title'],
        content=issue['content'][:350],
        status = issue['status'])
        filename, file = get_image_for_issue(service, issue)
        if filename:
            db_issue.image.save(filename, file)
        db_issue.save()
        if not settings.DEBUG:
            create_comment(db_issue)

    ends = issue['limit']
    hour_day = ends[-1]
    number = ends.rstrip(hour_day)
    if hour_day == "h":
        limit = datetime.timedelta(hours=int(number))
    else:
        limit = datetime.timedelta(days=int(number))
    bounty = Bounty(user=request.user, issue=db_issue, price=issue['bounty'], ends=datetime.datetime.now()+limit )
    bounty.save()
    alert_watchers_increase(db_issue, int(request.GET.get('bounty', 0)))
    del request.session['issue']
    return True
开发者ID:atuljain,项目名称:coderbounty,代码行数:43,代码来源:utils.py

示例5: test_m2m_and_m2o

# 需要导入模块: from models import Issue [as 别名]
# 或者: from models.Issue import save [as 别名]
    def test_m2m_and_m2o(self):
        r = User.objects.create(username="russell")
        g = User.objects.create(username="gustav")

        i1 = Issue(num=1)
        i1.client = r
        i1.save()

        i2 = Issue(num=2)
        i2.client = r
        i2.save()
        i2.cc.add(r)

        i3 = Issue(num=3)
        i3.client = g
        i3.save()
        i3.cc.add(r)

        self.assertQuerysetEqual(
            Issue.objects.filter(client=r.id), [
                1,
                2,
            ],
            lambda i: i.num
        )
        self.assertQuerysetEqual(
            Issue.objects.filter(client=g.id), [
                3,
            ],
            lambda i: i.num
        )
        self.assertQuerysetEqual(
            Issue.objects.filter(cc__id__exact=g.id), []
        )
        self.assertQuerysetEqual(
            Issue.objects.filter(cc__id__exact=r.id), [
                2,
                3,
            ],
            lambda i: i.num
        )

        # These queries combine results from the m2m and the m2o relationships.
        # They're three ways of saying the same thing.
        self.assertQuerysetEqual(
            Issue.objects.filter(Q(cc__id__exact = r.id) | Q(client=r.id)), [
                1,
                2,
                3,
            ],
            lambda i: i.num
        )
        self.assertQuerysetEqual(
            Issue.objects.filter(cc__id__exact=r.id) | Issue.objects.filter(client=r.id), [
                1,
                2,
                3,
            ],
            lambda i: i.num
        )
        self.assertQuerysetEqual(
            Issue.objects.filter(Q(client=r.id) | Q(cc__id__exact=r.id)), [
                1,
                2,
                3,
            ],
            lambda i: i.num
        )
开发者ID:ssaltzman,项目名称:POET,代码行数:70,代码来源:tests.py

示例6: update_issues

# 需要导入模块: from models import Issue [as 别名]
# 或者: from models.Issue import save [as 别名]
def update_issues():
    """Fetch a list of "recent" petitions on Althingi and update our database
    accordingly.
    """

    session_num = get_last_session_num()

    session, created = Session.objects.get_or_create(session_num=session_num)
    if created:
        print 'Added session: %s' % session_num
    else:
        print 'Already have session: %s' % session_num

    issue_list_xml = minidom.parse(urllib.urlopen(ISSUE_LIST_URL % session_num))

    issues_xml = issue_list_xml.getElementsByTagName(u'mál')

    for issue_xml in issues_xml:

        name = issue_xml.getElementsByTagName(u'málsheiti')[0].firstChild.nodeValue

        description = issue_xml.getElementsByTagName(u'efnisgreining')[0].firstChild
        description = description.nodeValue if description != None else 'engin lýsing útgefin'

        issue_type = issue_xml.getElementsByTagName(u'málstegund')[0].getAttribute(u'málstegund')

        issue_num = int(issue_xml.getAttribute(u'málsnúmer'))

        issue_try = Issue.objects.filter(issue_num=issue_num, session=session)
        if issue_try.count() > 0:
            issue = issue_try[0]

            print 'Already have issue: %s' % issue
        else:
            issue = Issue()
            issue.issue_num = issue_num
            issue.issue_type = issue_type
            issue.name = name
            issue.description = description
            issue.session = session
            issue.save()

            print 'Added issue: %s' % issue

        # Import the issue's documents.
        issue_xml = minidom.parse(urllib.urlopen(ISSUE_URL % (session_num, issue.issue_num)))
        docs_xml = issue_xml.getElementsByTagName(u'þingskjöl')[0].getElementsByTagName(u'þingskjal')

        lowest_doc_num = 0  # Lowest document number will always be the main document of the issue.
        for doc_xml in docs_xml:
            # Make sure that this is indeed the correct issue.
            if int(doc_xml.getAttribute(u'málsnúmer')) != issue.issue_num or int(doc_xml.getAttribute(u'þingnúmer')) != session_num:
                continue

            doc_num = int(doc_xml.getAttribute(u'skjalsnúmer'))
            doc_type = doc_xml.getElementsByTagName(u'skjalategund')[0].firstChild.nodeValue
            time_published = doc_xml.getElementsByTagName(u'útbýting')[0].firstChild.nodeValue + "+00:00"

            paths_xml =  doc_xml.getElementsByTagName(u'slóð')
            html_paths_xml = paths_xml[0].getElementsByTagName(u'html') 
            pdf_paths_xml = paths_xml[0].getElementsByTagName(u'pdf')
            if len(html_paths_xml) == 0:
                print 'Document not published: %d' % doc_num
                continue

            path_html = html_paths_xml[0].firstChild.nodeValue
            path_pdf = pdf_paths_xml[0].firstChild.nodeValue

            if lowest_doc_num == 0:
                lowest_doc_num = doc_num
            elif lowest_doc_num > doc_num:
                lowest_doc_num = doc_num

            doc_try = Document.objects.filter(doc_num=doc_num, issue=issue)
            if doc_try.count() > 0:
                doc = doc_try[0]

                print 'Already have document: %s' % doc
            else:
                doc = Document()
                doc.doc_num = doc_num
                doc.doc_type = doc_type
                doc.time_published = time_published
                doc.path_html = path_html
                doc.path_pdf = path_pdf
                doc.issue = issue
                doc.save()

                print '- Added document: %s' % doc

        if lowest_doc_num == 0:
            issue.delete()
            print '- Has no documents, being removed'
            continue

        main_doc = Document.objects.get(issue=issue, doc_num=lowest_doc_num)
        main_doc.is_main = True
        main_doc.save()

        print '- Main document determined to be: %s' % main_doc
开发者ID:thorgnyr,项目名称:safetyvalve,代码行数:102,代码来源:utils.py


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