Switch to unified view

a/Allura/allura/model/repo.py b/Allura/allura/model/repo.py
1
from datetime import datetime
1
from datetime import datetime
2
2
3
from ming import Document, Field
3
from ming import Document, Field
4
from ming import schema as S
4
from ming import schema as S
5
5
6
from .session import main_doc_session
6
from .session import main_doc_session, project_doc_session
7
7
8
class Commit(Document):
8
class Commit(Document):
9
    class __mongometa__:
9
    class __mongometa__:
10
        name = 'repo_ci'
10
        name = 'repo_ci'
11
        session = main_doc_session
11
        session = main_doc_session
...
...
37
                if line: summary.append(line)
37
                if line: summary.append(line)
38
                else: return ' '.join(summary)
38
                else: return ' '.join(summary)
39
            return ' '.join(summary)
39
            return ' '.join(summary)
40
        return ''
40
        return ''
41
41
42
    def url(self):
43
        return ''
44
45
    def shorthand_id(self):
46
        return ''
47
48
    @property
49
    def author_url(self):
50
        return ''
51
42
class Tree(Document):
52
class Tree(Document):
43
    class __mongometa__:
53
    class __mongometa__:
44
        name = 'repo_tree'
54
        name = 'repo_tree'
45
        session = main_doc_session
55
        session = main_doc_session
46
    ObjType=S.OneOf('blob', 'tree', 'submodule')
56
    ObjType=S.OneOf('blob', 'tree', 'submodule')
47
57
48
    _id = Field(str)
58
    _id = Field(str)
49
    tree_ids = Field([dict(name=str, id=str)])
59
    tree_ids = Field([dict(name=str, id=str)])
50
    blob_ids = Field([dict(name=str, id=str)])
60
    blob_ids = Field([dict(name=str, id=str)])
51
    other_ids = Field([dict(name=str, id=str, type=ObjType)])
61
    other_ids = Field([dict(name=str, id=str, type=ObjType)])
62
63
class LastCommit(Document):
64
    class __mongometa__:
65
        name = 'repo_last_commit'
66
        session = project_doc_session
67
        indexes = [
68
            ( 'repo_id', 'object_id'),
69
            ]
70
71
    _id = Field(str)
72
    repo_id=Field(S.ObjectId())
73
    object_id=Field(str)
74
    commit_info = Field(dict(
75
        id=str,
76
        date=datetime,
77
        author=str,
78
        author_email=str,
79
        author_url=str,
80
        href=str,
81
        shortlink=str,
82
        summary=str))
83
84
    @classmethod
85
    def set_last_commit(cls, repo_id, oid, commit):
86
        lc = cls(dict(
87
                _id='%s:%s' % (repo_id, oid),
88
                repo_id=repo_id,
89
                object_id=oid,
90
                commit_info=dict(
91
                    id=commit._id,
92
                    author=commit.authored.name,
93
                    author_email=commit.authored.email,
94
                    author_url=commit.author_url,
95
                    date=commit.authored.date,
96
                    href=commit.url(),
97
                    shortlink=commit.shorthand_id(),
98
                    summary=commit.summary)))
99
        lc.m.save(safe=False)
100
        return lc
52
101
53
class Trees(Document):
102
class Trees(Document):
54
    class __mongometa__:
103
    class __mongometa__:
55
        name = 'repo_trees'
104
        name = 'repo_trees'
56
        session = main_doc_session
105
        session = main_doc_session