1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-19 01:44:13 +00:00

[api]Add comment attached to file

This commit is contained in:
poetwang
2013-08-03 15:19:23 +08:00
parent 70eff3be40
commit 7519bb9c20
2 changed files with 18 additions and 3 deletions

View File

@@ -31,14 +31,14 @@ urlpatterns = patterns('',
url(r'^html/discussion/(?P<msg_id>\d+)/$', DiscussionHtml.as_view(), name="api_discussion"), url(r'^html/discussion/(?P<msg_id>\d+)/$', DiscussionHtml.as_view(), name="api_discussion"),
url(r'^html/more_discussions/(?P<group_id>\d+)/$', AjaxDiscussions.as_view(), name="more_discussions"), url(r'^html/more_discussions/(?P<group_id>\d+)/$', AjaxDiscussions.as_view(), name="more_discussions"),
url(r'^html/newreply/$', NewReplyHtml.as_view()), url(r'^html/newreply/$', NewReplyHtml.as_view()),
url(r'^html/newreply2/$', api_new_replies),
# Folowing is only for debug, will be removed # Folowing is only for debug, will be removed
url(r'^html/events2/$', activity2), #url(r'^html/newreply2/$', api_new_replies),
#url(r'^html/events2/$', activity2),
#url(r'^html/more_events/$', events2), #url(r'^html/more_events/$', events2),
#url(r'^html/repo_history_changes/(?P<repo_id>[-0-9a-f]{36})/$', api_repo_history_changes, name='api_repo_history_changes'), #url(r'^html/repo_history_changes/(?P<repo_id>[-0-9a-f]{36})/$', api_repo_history_changes, name='api_repo_history_changes'),
url(r'^html/discussions2/(?P<group_id>\d+)/$', discussions2, name="api_discussions2"), #url(r'^html/discussions2/(?P<group_id>\d+)/$', discussions2, name="api_discussions2"),
#url(r'^html/discussion/(?P<msg_id>\d+)/$', discussion2, name="api_discussion2"), #url(r'^html/discussion/(?P<msg_id>\d+)/$', discussion2, name="api_discussion2"),
#url(r'^html/more_discussions/(?P<group_id>\d+)/$', more_discussions2, name="more_discussions"), #url(r'^html/more_discussions/(?P<group_id>\d+)/$', more_discussions2, name="more_discussions"),

View File

@@ -22,6 +22,7 @@ from authentication import TokenAuthentication
from permissions import IsRepoWritable, IsRepoAccessible, IsRepoOwner from permissions import IsRepoWritable, IsRepoAccessible, IsRepoOwner
from serializers import AuthTokenSerializer from serializers import AuthTokenSerializer
from seahub.base.accounts import User from seahub.base.accounts import User
from seahub.base.models import FileDiscuss
from seahub.share.models import FileShare from seahub.share.models import FileShare
from seahub.views import access_to_repo, validate_owner, is_registered_user, events, group_events_data, get_diff from seahub.views import access_to_repo, validate_owner, is_registered_user, events, group_events_data, get_diff
from seahub.utils import gen_file_get_url, gen_token, gen_file_upload_url, \ from seahub.utils import gen_file_get_url, gen_token, gen_file_upload_url, \
@@ -214,6 +215,7 @@ class Repos(APIView):
"type":"grepo", "type":"grepo",
"id":r.id, "id":r.id,
"owner":group.group_name, "owner":group.group_name,
"groupid":group.id,
"name":r.name, "name":r.name,
"desc":r.desc, "desc":r.desc,
"mtime":r.latest_modify, "mtime":r.latest_modify,
@@ -1242,6 +1244,19 @@ def group_discuss(request, group):
grpmsg_added.send(sender=GroupMessage, group_id=group.id, grpmsg_added.send(sender=GroupMessage, group_id=group.id,
from_email=username) from_email=username)
repo_id = request.POST.get('repo_id', None)
path = request.POST.get('path', None)
if repo_id and path:
# save attachment
ma = MessageAttachment(group_message=message, repo_id=repo_id,
attach_type='file', path=path,
src='recommend')
ma.save()
# save discussion
fd = FileDiscuss(group_message=message, repo_id=repo_id, path=path)
fd.save()
ctx = {} ctx = {}
ctx['msg'] = message ctx['msg'] = message
html = render_to_string("api2/discussion_posted.html", ctx) html = render_to_string("api2/discussion_posted.html", ctx)