當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。