mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-18 08:16:07 +00:00
[api]Add comment attached to file
This commit is contained in:
@@ -31,14 +31,14 @@ urlpatterns = patterns('',
|
||||
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/newreply/$', NewReplyHtml.as_view()),
|
||||
url(r'^html/newreply2/$', api_new_replies),
|
||||
|
||||
# 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/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/more_discussions/(?P<group_id>\d+)/$', more_discussions2, name="more_discussions"),
|
||||
|
||||
|
@@ -22,6 +22,7 @@ from authentication import TokenAuthentication
|
||||
from permissions import IsRepoWritable, IsRepoAccessible, IsRepoOwner
|
||||
from serializers import AuthTokenSerializer
|
||||
from seahub.base.accounts import User
|
||||
from seahub.base.models import FileDiscuss
|
||||
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.utils import gen_file_get_url, gen_token, gen_file_upload_url, \
|
||||
@@ -214,6 +215,7 @@ class Repos(APIView):
|
||||
"type":"grepo",
|
||||
"id":r.id,
|
||||
"owner":group.group_name,
|
||||
"groupid":group.id,
|
||||
"name":r.name,
|
||||
"desc":r.desc,
|
||||
"mtime":r.latest_modify,
|
||||
@@ -1242,6 +1244,19 @@ def group_discuss(request, group):
|
||||
grpmsg_added.send(sender=GroupMessage, group_id=group.id,
|
||||
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['msg'] = message
|
||||
html = render_to_string("api2/discussion_posted.html", ctx)
|
||||
|
Reference in New Issue
Block a user