mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-10 03:11:07 +00:00
rm unused code & file for 'file comment'
This commit is contained in:
@@ -19,22 +19,6 @@ class UuidObjidMap(models.Model):
|
|||||||
uuid = models.CharField(max_length=40)
|
uuid = models.CharField(max_length=40)
|
||||||
obj_id = models.CharField(max_length=40, unique=True)
|
obj_id = models.CharField(max_length=40, unique=True)
|
||||||
|
|
||||||
class FileComment(models.Model):
|
|
||||||
"""
|
|
||||||
Model used for leave comment on file.
|
|
||||||
NOTE:
|
|
||||||
Need manually create index for (file_path_hash, repo_id).
|
|
||||||
"""
|
|
||||||
repo_id = models.CharField(max_length=36, db_index=True)
|
|
||||||
file_path = models.TextField()
|
|
||||||
file_path_hash = models.CharField(max_length=12)
|
|
||||||
from_email = models.EmailField()
|
|
||||||
message = models.TextField()
|
|
||||||
timestamp = models.DateTimeField(default=datetime.datetime.now)
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
ordering = ['-timestamp']
|
|
||||||
|
|
||||||
class FileDiscuss(models.Model):
|
class FileDiscuss(models.Model):
|
||||||
"""
|
"""
|
||||||
Model used to represents the relationship between group message and file/dir.
|
Model used to represents the relationship between group message and file/dir.
|
||||||
|
@@ -1,16 +0,0 @@
|
|||||||
{% load seahub_tags avatar_tags%}
|
|
||||||
{% load url from future %}
|
|
||||||
|
|
||||||
{% for comment in comments %}
|
|
||||||
<li class="comment ovhd">
|
|
||||||
<a class="pic fleft" href="{% url 'user_profile' comment.from_email %}">{% avatar comment.from_email 48 %}</a>
|
|
||||||
<div class="txt fright">
|
|
||||||
<div class="comment-hd w100 ovhd">
|
|
||||||
<a href="{% url 'user_profile' comment.from_email %}" title="{{ comment.from_email }}" class="fleft">{{ comment.from_email|email2nickname }}</a>
|
|
||||||
<span class="time fright">{{ comment.timestamp|translate_seahub_time }}</span>
|
|
||||||
</div>
|
|
||||||
<p class="comment-bd">{{ comment.message|seahub_urlize|find_at|linebreaksbr }}</p>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
|
|
1
urls.py
1
urls.py
@@ -69,7 +69,6 @@ urlpatterns = patterns('',
|
|||||||
url(r'^d/(?P<token>[a-f0-9]{10})/files/$', view_file_via_shared_dir, name='view_file_via_shared_dir'),
|
url(r'^d/(?P<token>[a-f0-9]{10})/files/$', view_file_via_shared_dir, name='view_file_via_shared_dir'),
|
||||||
(r'^file_upload_progress_page/$', file_upload_progress_page),
|
(r'^file_upload_progress_page/$', file_upload_progress_page),
|
||||||
(r'^events/$', events),
|
(r'^events/$', events),
|
||||||
(r'^file_comment/$', file_comment),
|
|
||||||
(r'^pdf_full_view/$', pdf_full_view),
|
(r'^pdf_full_view/$', pdf_full_view),
|
||||||
url(r'^i18n/$', i18n, name='i18n'),
|
url(r'^i18n/$', i18n, name='i18n'),
|
||||||
(r'^download/repo/$', repo_download),
|
(r'^download/repo/$', repo_download),
|
||||||
|
@@ -47,7 +47,7 @@ from pysearpc import SearpcError
|
|||||||
|
|
||||||
from seahub.base.accounts import User
|
from seahub.base.accounts import User
|
||||||
from seahub.base.decorators import sys_staff_required
|
from seahub.base.decorators import sys_staff_required
|
||||||
from seahub.base.models import UuidObjidMap, FileComment, InnerPubMsg, InnerPubMsgReply
|
from seahub.base.models import UuidObjidMap, InnerPubMsg, InnerPubMsgReply
|
||||||
from seahub.contacts.models import Contact
|
from seahub.contacts.models import Contact
|
||||||
from seahub.contacts.signals import mail_sended
|
from seahub.contacts.signals import mail_sended
|
||||||
from seahub.group.forms import MessageForm, MessageReplyForm
|
from seahub.group.forms import MessageForm, MessageReplyForm
|
||||||
@@ -990,56 +990,6 @@ def repo_del_file(request, repo_id):
|
|||||||
|
|
||||||
url = reverse('repo', args=[repo_id]) + ('?p=%s' % urllib2.quote(parent_dir.encode('utf-8')))
|
url = reverse('repo', args=[repo_id]) + ('?p=%s' % urllib2.quote(parent_dir.encode('utf-8')))
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
def file_comment(request):
|
|
||||||
if request.method == 'POST':
|
|
||||||
# handle post request to leave comment on a file
|
|
||||||
content_type = 'application/json; charset=utf-8'
|
|
||||||
path = request.GET.get('p', '')
|
|
||||||
|
|
||||||
f = FileCommentForm(request.POST)
|
|
||||||
if f.is_valid():
|
|
||||||
repo_id = f.cleaned_data['repo_id']
|
|
||||||
file_path = f.cleaned_data['file_path']
|
|
||||||
file_path_hash = md5_constructor(file_path).hexdigest()[:12]
|
|
||||||
message = f.cleaned_data['message']
|
|
||||||
fc = FileComment(repo_id=repo_id, file_path=file_path,
|
|
||||||
file_path_hash=file_path_hash,
|
|
||||||
from_email=request.user.username, message=message)
|
|
||||||
fc.save()
|
|
||||||
|
|
||||||
# Get repo groups
|
|
||||||
org, base_template = check_and_get_org_by_repo(repo_id,
|
|
||||||
request.user.username)
|
|
||||||
if org:
|
|
||||||
repo_shared_groups = get_org_groups_by_repo(org.org_id,
|
|
||||||
repo_id)
|
|
||||||
else:
|
|
||||||
repo_shared_groups = get_shared_groups_by_repo(repo_id)
|
|
||||||
|
|
||||||
for group in repo_shared_groups:
|
|
||||||
# save group message, and length should be less than 500
|
|
||||||
gm = GroupMessage(group_id=group.id,
|
|
||||||
from_email=request.user.username,
|
|
||||||
message=message[:500])
|
|
||||||
gm.save()
|
|
||||||
# send signal
|
|
||||||
grpmsg_added.send(sender=GroupMessage, group_id=group.id,
|
|
||||||
from_email=request.user.username)
|
|
||||||
|
|
||||||
# save attachment
|
|
||||||
ma = MessageAttachment(group_message=gm, repo_id=repo_id,
|
|
||||||
attach_type='file', path=path,
|
|
||||||
src='filecomment')
|
|
||||||
ma.save()
|
|
||||||
|
|
||||||
comments = FileComment.objects.filter(file_path_hash=file_path_hash,
|
|
||||||
repo_id=repo_id)
|
|
||||||
html = render_to_string("file_comments.html", {
|
|
||||||
'comments':comments})
|
|
||||||
return HttpResponse(json.dumps({'html': html}),
|
|
||||||
content_type=content_type)
|
|
||||||
|
|
||||||
|
|
||||||
def repo_file_get(raw_path, file_enc):
|
def repo_file_get(raw_path, file_enc):
|
||||||
err = ''
|
err = ''
|
||||||
|
@@ -30,7 +30,7 @@ from pysearpc import SearpcError
|
|||||||
|
|
||||||
from auth.decorators import login_required
|
from auth.decorators import login_required
|
||||||
from base.decorators import repo_passwd_set_required
|
from base.decorators import repo_passwd_set_required
|
||||||
from base.models import UuidObjidMap, FileComment
|
from base.models import UuidObjidMap
|
||||||
from contacts.models import Contact
|
from contacts.models import Contact
|
||||||
from share.models import FileShare
|
from share.models import FileShare
|
||||||
from seahub.utils import get_httpserver_root, show_delete_days, render_error, \
|
from seahub.utils import get_httpserver_root, show_delete_days, render_error, \
|
||||||
@@ -278,7 +278,6 @@ def view_file(request, repo_id):
|
|||||||
# construct some varibles
|
# construct some varibles
|
||||||
u_filename = os.path.basename(path)
|
u_filename = os.path.basename(path)
|
||||||
filename_utf8 = urllib2.quote(u_filename.encode('utf-8'))
|
filename_utf8 = urllib2.quote(u_filename.encode('utf-8'))
|
||||||
comment_open = request.GET.get('comment_open', '')
|
|
||||||
current_commit = get_commits(repo_id, 0, 1)[0]
|
current_commit = get_commits(repo_id, 0, 1)[0]
|
||||||
|
|
||||||
# Check whether user has permission to view file and get file raw path,
|
# Check whether user has permission to view file and get file raw path,
|
||||||
@@ -371,9 +370,7 @@ def view_file(request, repo_id):
|
|||||||
else:
|
else:
|
||||||
repogrp_str = ''
|
repogrp_str = ''
|
||||||
|
|
||||||
# fetch file comments
|
|
||||||
file_path_hash = md5_constructor(urllib2.quote(path.encode('utf-8'))).hexdigest()[:12]
|
file_path_hash = md5_constructor(urllib2.quote(path.encode('utf-8'))).hexdigest()[:12]
|
||||||
comments = FileComment.objects.filter(file_path_hash=file_path_hash, repo_id=repo_id)
|
|
||||||
|
|
||||||
# fetch file contributors and latest contributor
|
# fetch file contributors and latest contributor
|
||||||
contributors, last_modified, last_commit_id = get_file_contributors(repo_id, path.encode('utf-8'), file_path_hash, obj_id)
|
contributors, last_modified, last_commit_id = get_file_contributors(repo_id, path.encode('utf-8'), file_path_hash, obj_id)
|
||||||
@@ -410,8 +407,6 @@ def view_file(request, repo_id):
|
|||||||
'filetype': ret_dict['filetype'],
|
'filetype': ret_dict['filetype'],
|
||||||
"applet_root": get_ccnetapplet_root(),
|
"applet_root": get_ccnetapplet_root(),
|
||||||
'groups': groups,
|
'groups': groups,
|
||||||
'comments': comments,
|
|
||||||
'comment_open':comment_open,
|
|
||||||
'DOCUMENT_CONVERTOR_ROOT': DOCUMENT_CONVERTOR_ROOT,
|
'DOCUMENT_CONVERTOR_ROOT': DOCUMENT_CONVERTOR_ROOT,
|
||||||
'use_pdfjs':USE_PDFJS,
|
'use_pdfjs':USE_PDFJS,
|
||||||
'contributors': contributors,
|
'contributors': contributors,
|
||||||
|
Reference in New Issue
Block a user