db.create_table('dvcs_change', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('author', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'], null=True, blank=True)),
+ ('author_desc', self.gf('django.db.models.fields.CharField')(max_length=128, null=True, blank=True)),
('patch', self.gf('django.db.models.fields.TextField')(blank=True)),
('tree', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['dvcs.Document'])),
('revision', self.gf('django.db.models.fields.IntegerField')(db_index=True)),
'dvcs.change': {
'Meta': {'ordering': "('created_at',)", 'unique_together': "(['tree', 'revision'],)", 'object_name': 'Change'},
'author': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'}),
+ 'author_desc': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}),
'created_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'db_index': 'True'}),
'description': ('django.db.models.fields.TextField', [], {'default': "''", 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
Data contains a pickled diff needed to reproduce the initial document.
"""
author = models.ForeignKey(User, null=True, blank=True)
+ author_desc = models.CharField(max_length=128, null=True, blank=True)
patch = models.TextField(blank=True)
tree = models.ForeignKey('Document')
revision = models.IntegerField(db_index=True)
def __unicode__(self):
return u"Id: %r, Tree %r, Parent %r, Patch '''\n%s'''" % (self.id, self.tree_id, self.parent_id, self.patch)
+ def author_str(self):
+ if self.author:
+ return "%s %s <%s>" % (
+ self.author.first_name,
+ self.author.last_name,
+ self.author.email)
+ else:
+ return self.author_desc
+
+
def save(self, *args, **kwargs):
"""
take the next available revision number if none yet
text = change.apply_to(text)
return text
- def make_child(self, patch, author, description):
+ def make_child(self, patch, description, author=None, author_desc=None):
return self.children.create(patch=patch,
tree=self.tree, author=author,
+ author_desc=author_desc,
description=description)
- def make_merge_child(self, patch, author, description):
+ def make_merge_child(self, patch, description, author=None,
+ author_desc=None):
return self.merge_children.create(patch=patch,
tree=self.tree, author=author,
+ author_desc=author_desc,
description=description)
def apply_to(self, text):
return mdiff.patch(text, pickle.loads(self.patch.encode('ascii')))
- def merge_with(self, other, author, description=u"Automatic merge."):
+ def merge_with(self, other, author=None, author_desc=None,
+ description=u"Automatic merge."):
assert self.tree_id == other.tree_id # same tree
if other.parent_id == self.pk:
# immediate child
patch = self.make_patch(local, result)
return self.children.create(
patch=patch, merge_parent=other, tree=self.tree,
- author=author, description=description)
+ author=author, author_desc=author_desc,
+ description=description)
def revert(self, **kwargs):
""" commit this version of a doc as new head """
patch = kwargs['patch']
author = kwargs.get('author', None)
+ author_desc = kwargs.get('author_desc', None)
old_head = self.head
if parent != old_head:
- change = parent.make_merge_child(patch, author, kwargs.get('description', ''))
+ change = parent.make_merge_child(patch, author=author,
+ author_desc=author_desc,
+ description=kwargs.get('description', ''))
# not Fast-Forward - perform a merge
- self.head = old_head.merge_with(change, author=author)
+ self.head = old_head.merge_with(change, author=author,
+ author_desc=author_desc)
else:
- self.head = parent.make_child(patch, author, kwargs.get('description', ''))
+ self.head = parent.make_child(patch, author=author,
+ author_desc=author_desc,
+ description=kwargs.get('description', ''))
self.save()
return self.head
maxrev = entry.filerev()
gallery_link = None;
for rev in xrange(maxrev + 1):
- # TODO: author, tags, gallery
+ # TODO: tags
fctx = entry.filectx(rev)
data = fctx.data()
gallery_link = gallery(fname, data)
patch=make_patch(old_data, data),
created_at=datetime.datetime.fromtimestamp(fctx.date()[0]),
description=fctx.description().decode("utf-8", 'replace'),
+ author_desc=fctx.user().decode("utf-8", 'replace'),
parent=chunk.head
)
chunk.head = head
'dvcs.change': {
'Meta': {'ordering': "('created_at',)", 'unique_together': "(['tree', 'revision'],)", 'object_name': 'Change'},
'author': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'}),
+ 'author_desc': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}),
'created_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'db_index': 'True'}),
'description': ('django.db.models.fields.TextField', [], {'default': "''", 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
<tbody>
{% for book in books %}
<tr>
- <td><a target="_blank" data-id="{{ book.slug }}"
- href="{% url wiki_book book.slug %}">{{ book.title }}</a>
- </td>
- <td class='listitem-tools'>
+ <td colspan="3">
+ <a target="_blank" data-id="{{ book.slug }}"
+ href="{% url wiki_book book.slug %}">[?]</a>
{% ifequal book.chunk_set.count 1 %}
<a target="_blank" data-id="{{ book.slug }}"
href="{% url wiki_editor book.slug %}">
- [{% trans "edit" %}]</a>
+ {{ book.title }}</a>
{% else %}
+ {{ book.title }}
+ <div class="chunk-list">
{% for chunk in book %}
<a target="_blank" data-id="{{ book.slug }}"
href="{{ chunk.get_absolute_url }}">
- [<span class='chunkno'>{{ forloop.counter }}.</span>
- {{ chunk.comment }}</a>]<br/>
+ <span class='chunkno'>{{ forloop.counter }}.</span>
+ {{ chunk.comment }}</a><br/>
{% endfor %}
+ </div>
{% endifequal %}
</td>
<!-- placeholder </td> -->