1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-18 16:36:15 +00:00

[grp discuss] display image if the attachment is a image file

This commit is contained in:
llj
2013-03-28 20:00:39 +08:00
committed by zhengxie
parent 28527cb99c
commit af5897d540
3 changed files with 33 additions and 5 deletions

View File

@@ -83,8 +83,16 @@
<div class="msg-attachment">
{% if ma.src == 'recommend' %}
{% if ma.attach_type == 'file' %}
<img src="{{ MEDIA_URL }}img/file/{{ ma.name|file_icon_filter }}" alt="{% trans "File"%}" height="18" class="vam" />
<a href="{% url 'repo_view_file' ma.repo_id %}?p={{ ma.path|urlencode }}" target="_blank" class="vam">{{ ma.name }}</a>
{% if ma.filetype != 'Image'%}
<img src="{{ MEDIA_URL }}img/file/{{ ma.name|file_icon_filter }}" alt="{% trans "File"%}" height="18" class="vam" />
<a href="{% url 'repo_view_file' ma.repo_id %}?p={{ ma.path|urlencode }}" target="_blank" class="vam">{{ ma.name }}</a>
{% else %}
{% if ma.err %}
<p class="error">{{ma.err}}</p>
{% else %}
<a href="{% url 'repo_view_file' ma.repo_id %}?p={{ ma.path|urlencode }}" target="_blank" class="img-cont"><img src="{{ma.img_url}}" alt="{{ma.name}}" class="img" /></a>
{% endif %}
{% endif %}
{% else %}
<img src="{{ MEDIA_URL }}img/folder-icon-24.png" alt="{% trans "Directory icon"%}" height="20" class="vam" />
<a href="{% url 'repo' ma.repo_id %}?p={{ ma.path|urlencode }}" target="_blank" class="vam">{{ ma.name }}</a>

View File

@@ -1051,6 +1051,16 @@ def group_discuss(request, group):
if path[-1] == '/':
path = path[:-1]
att.name = os.path.basename(path)
if att.attach_type == 'file' and att.src == 'recommend':
att.filetype, att.fileext = get_file_type_and_ext(att.name)
if att.filetype == 'Image':
att.obj_id = get_file_id_by_path(att.repo_id, path)
if not att.obj_id:
att.err = _(u'File does not exist')
else:
att.token = web_get_access_token(att.repo_id, att.obj_id, 'view', request.user.username)
att.img_url = gen_file_get_url(att.token, att.name)
msg.attachment = att
return render_to_response("group/group_discuss.html", {

View File

@@ -152,6 +152,7 @@ p {
.vh { visibility:hidden; }
.vam { vertical-align:middle; }
.italic { font-style:italic; }
.al-rt { text-align:right; }
.notification {
padding:5px;
background:#FDF;
@@ -161,9 +162,6 @@ p {
color:#808080;
font-size:12px;
}
.al-rt {
text-align:right;
}
.op,
.more {
font-weight:normal;
@@ -1520,6 +1518,18 @@ textarea:-moz-placeholder {/* for FF */
border-top:1px solid #e9e9e9;
margin-top:12px;
}
.msg-attachment .img-cont {
display:block;
text-align:center;
line-height:0;
background:#fcfcfc;
}
.msg-attachment .img {
width:auto;
height:auto;
max-width:100%;
max-height:300px;
}
.msg-hd .author {
font-weight:bold;
}