1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-04 16:31:13 +00:00

Can repo to group

This commit is contained in:
plt
2011-09-10 20:07:46 +08:00
parent 6e3bd53397
commit ead966c6e2
6 changed files with 173 additions and 4 deletions

View File

@@ -101,6 +101,7 @@ INSTALLED_APPS = (
'avatar',
'seahub.base',
'seahub.profile',
'seahub.group',
)
AUTHENTICATION_BACKENDS = (

77
templates/group.html Normal file
View File

@@ -0,0 +1,77 @@
{% extends "base.html" %}
{% block title %}Group{% endblock %}
{% block left_panel %}
<ul>
<li><a href="{{ SITE_ROOT }}group/{{ group.props.id }}/addrepo/">Add Repo</a></li>
</ul>
{% endblock %}
{% block right_panel %}
<p>Use the following command to add a group:</p>
<div><code>ccnet-tool group-follow &lt;group-id&gt; &lt;rendevous-id&gt;</code></div>
<h3>Group</h3>
<table class="default">
<tr>
<td>Name</td>
<td>{{ group.props.name }}</td>
</tr>
<tr>
<td>ID</td>
<td>{{ group.props.id }}</td>
</tr>
<tr>
<td>Timestamp</td>
<td>{{ group.props.timestamp }}</td>
</tr>
<tr>
<td>Rendezvous</td>
<td>{{ group.props.rendezvous }}</td>
</tr>
<tr>
<td>Creator</td>
<td>{{ group.props.creator }}</td>
</tr>
<tr>
<td>Maintainer</td>
<td>
{% for peer in group.maintainers %}
{{peer}}
{% endfor %}
</td>
</tr>
<tr>
<td>Members</td>
<td>
{% for peer in group.members %}
{{peer}}
{% endfor %}
</td>
</tr>
<tr>
<td>Followers</td>
<td>
{% for peer in group.followers %}
{{peer}}
{% endfor %}
</td>
</tr>
</table>
<h3>repos</h3>
<table class="default">
<tr>
<th>Repo ID</th>
</tr>
{% for item in shared_repos %}
<tr>
<td>{{ item.repo_id }}</td>
</tr>
{% endfor %}
</table>
{% endblock %}

View File

@@ -0,0 +1,22 @@
{% extends "base.html" %}
{% block title %}Group{% endblock %}
{% block left_panel %}
{% endblock %}
{% block right_panel %}
Add repo to {{ group.props.name }}
<form action="" method="post">
{% if error_msg %}
<p class="error">{{ error_msg }}</p>
{% endif %}
<label>Repo ID:</label><br/>
{{ form.repo_id }}
<input type="submit" value="Submit" />
</form>
{% endblock %}

View File

@@ -1 +1,23 @@
{% extends "base.html" %}
{% block left_panel %}
Welcome.
{% endblock %}
{% block right_panel %}
<h2>What's Ccnet</h2>
<p>Ccnet is a group oriented communication and file sharing tool. </p>
<p>It provide two basic functions:<p>
<ul>
<li>Versioned data sharing and synchronization.</li>
<li>Group oriented message communication.</li>
</ul>
<p>Features:</p>
<ul>
<li>data is at users' control</li>
</ul>
{% endblock %}

View File

@@ -1,7 +1,7 @@
from django.conf.urls.defaults import *
from django.conf import settings
from seahub.views import root, home, peers, groups, myhome, myrepos, \
repo
repo, group, group_add_repo
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
@@ -25,7 +25,9 @@ urlpatterns = patterns('',
(r'^home/my/$', myhome),
(r'^peers/$', peers),
(r'^groups/$', groups),
(r'^repo/(?P<repo_id>[^/]+)/', repo),
url(r'^group/(?P<group_id>[^/]+)/$', group, name='view_group'),
(r'^group/(?P<group_id>[^/]+)/addrepo/$', group_add_repo),
(r'^repo/(?P<repo_id>[^/]+)/$', repo),
(r'^repos/my/$', myrepos),
(r'^avatar/', include('avatar.urls')),

View File

@@ -3,9 +3,14 @@ from django.shortcuts import render_to_response
from django.core.urlresolvers import reverse
from django.template import RequestContext
from django.contrib.auth.decorators import login_required
from django.db import IntegrityError
from seaserv import cclient, ccnet_rpc, get_groups, get_users, get_repos, \
get_repo, get_commits, get_branches, seafile_rpc
get_repo, get_commits, get_branches, seafile_rpc, get_group
from seahub.profile.models import UserProfile
from seahub.group.models import GroupRepo
from seahub.group.forms import GroupAddRepoForm
def get_user_cid(user):
@@ -15,7 +20,6 @@ def get_user_cid(user):
except UserProfile.DoesNotExist:
return None
from seahub.profile.models import UserProfile
def root(request):
if request.user.is_authenticated():
@@ -58,6 +62,47 @@ def groups(request):
}, context_instance=RequestContext(request))
def group(request, group_id):
"""Show a group.
Login is not required, but permission check based on token should
be added later.
"""
group = get_group(group_id)
shared_repos = GroupRepo.objects.filter(group_id=group_id)
return render_to_response('group.html', {
'group': group, 'shared_repos': shared_repos,
}, context_instance=RequestContext(request))
def group_add_repo(request, group_id):
"""Add a repo to a group"""
group = get_group(group_id)
if not group:
raise Http404
if request.method == 'POST':
form = GroupAddRepoForm(request.POST)
if form.is_valid():
group_repo = GroupRepo()
group_repo.group_id = group_id
group_repo.repo_id = form.cleaned_data['repo_id']
try:
group_repo.save()
except IntegrityError:
# catch the case repo added to group before
pass
return HttpResponseRedirect(reverse('view_group', args=[group_id]))
else:
form = GroupAddRepoForm()
return render_to_response("group_add_repo.html", {
'form': form, 'group': group
}, context_instance=RequestContext(request))
def repo(request, repo_id):
# TODO: check permission
repo = get_repo(repo_id)