Skip to content
This repository has been archived by the owner on Dec 31, 2021. It is now read-only.

Thumbs #134

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions deploy/media/css/spc-extend.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ body {
.pointer {
cursor: pointer;
}
.block-inline {
display: inline-block;
}
.header {
padding-top: 15px;
padding-bottom: 15px;
Expand All @@ -32,6 +35,9 @@ body {
.pointer {
cursor: pointer;
}
.block-inline {
display: inline-block;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this repeated again? The same for pointer.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the "less" compilation is making this mistake. There seems to be quite a bit duplicate code.
We can create a new PR removing this error and correcting it.
Actually, we can't remove these css files from repo and only depend on less files each time to compile..
The reason is, these css files come under static files. {{static}} template tag won't work if we remove.

}
.tags .btn {
border: none;
font-size: 9.5px;
Expand Down Expand Up @@ -85,6 +91,54 @@ body {
#spc-comment-edit-modal .tab-content {
min-height: 228px;
}
.up-arrow {
width: 0;
height: 0;
color: #999999;
border-top: 0px solid;
border-bottom: 15px solid;
border-left: 18px solid transparent;
border-right: 18px solid transparent;
marign: 0 auto;
margin-bottom: 3px;
}
.up-arrow.active {
color: #f59d18;
}
.up-arrow-comment {
width: 0;
height: 0;
color: #999999;
border-top: 0px solid;
border-bottom: 8px solid;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
}
.up-arrow-comment.active {
color: #f59d18;
}
.down-arrow {
width: 0;
height: 0;
color: #999999;
border-top: 15px solid;
border-bottom: 0px solid;
border-left: 18px solid transparent;
border-right: 18px solid transparent;
marign: 0 auto;
margin-top: 3px;
}
.down-arrow.active {
color: #f59d18;
}
#spc-comment-list .vote-count {
font-size: 11px;
}
.reputation {
font-weight: bold;
font-size: 18px;
color: #555555;
}
.spc-rightsidebar {
color: #555555;
padding: 2px 10px;
Expand Down
9 changes: 9 additions & 0 deletions deploy/media/js/spc-extend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
$('body').on('click', function (e) {
$('.spc-popover').each(function () {
//the 'is' for buttons that triggers popups
//the 'has' for icons within a button that triggers a popup
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a space between // and the start of the comment.

if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the last condition?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And shouldn't it be ||?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The piece of code I referred is http://stackoverflow.com/a/14857326/1162468

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you copied the code exactly like that. Do you understand what it does?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is looking at where on body onclick event happened and whether it happened on the popover or not. That was the first condition. I didn't understood why .length is used here

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't copy things you don't understand. Have a good read of this line, understand what it does, and then add a good comment on why this is written like this.

$(this).popover('hide');
}
});
});
49 changes: 49 additions & 0 deletions deploy/media/less/spc-content.less
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,52 @@
min-height: 228px;
}
}

// thumbs (reputation) arrows
.arrow (@top, @bottom, @left, @right) {
width: 0;
height:0;
color: @grayLight;
border-top: @top solid;
border-bottom: @bottom solid;
border-left: @left solid transparent;
border-right: @right solid transparent;
}

.up-arrow {
.arrow(0px, 15px, 18px, 18px);
marign: 0 auto;
margin-bottom: 3px;
&.active {
color: rgb(245, 157, 24);
}
}


.up-arrow-comment {
.arrow(0px, 8px, 6px, 6px);
&.active {
color: rgb(245, 157, 24);
}
}

.down-arrow {
.arrow(15px, 0px, 18px, 18px);
marign: 0 auto;
margin-top: 3px;
&.active {
color: rgb(245, 157, 24);
}
}

#spc-comment-list {
.vote-count {
font-size: 11px;
}
}

.reputation {
font-weight: bold;
font-size: 18px;
color: @gray;
}
4 changes: 4 additions & 0 deletions deploy/media/less/spc-utils.less
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@
.pointer {
cursor: pointer;
}

.block-inline {
display: inline-block;
}
1 change: 1 addition & 0 deletions deploy/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
'scipy_central.screenshot',
'scipy_central.pagehit',
'scipy_central.feeds',
'scipy_central.thumbs',
)

# Custom comments App
Expand Down
3 changes: 2 additions & 1 deletion deploy/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
{% include "base-includes/footer-outside.html" %}

<script src="{{STATIC_URL}}js/bootstrap.min.js"></script>
<script type="text/javascript" src="{{STATIC_URL}}js/spc-extend.js"></script>

<script type="text/javascript">
$('.dropdown-toggle').dropdown()
Expand All @@ -118,7 +119,7 @@
$('.accordion-group').collapse();
$('.accordion-group').on('show hide', function(e)
{
$(e.target).siblings('.accordion-heading').find('.accordion-toggle i').toggleClass('icon-arrow-down icon-arrow-up', 200);
$(e.target).siblings('.accordion-heading').find('.accordion-toggle i').toggleClass('icon-minus icon-plus', 200);
});
</script>

Expand Down
16 changes: 9 additions & 7 deletions deploy/templates/search/includes/one-search-result.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
{% if entry %}
{% load comments %}

<li class="media">
<a class="pull-left" href="#">
<div class="media">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should still be a li I believe. Especially since now we have a ul with divs inside...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

<div class="pull-left" href="#">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

divs don't have href attribute. Why did you change it?

<div class="text-center reputation">{{entry.reputation}}</div>
<div class="text-center muted">votes</div>
{% if entry.entry.sub_type == 'snippet' %}
<img src="{{STATIC_URL}}single-file-list-icon-tiny.png">
<img class="no-lead" src="{{STATIC_URL}}single-file-list-icon-tiny.png">
{% endif %}
{% if entry.entry.sub_type == 'package' %}
<img src="{{STATIC_URL}}multiple-file-list-icon-tiny.png">
<img class="no-lead" src="{{STATIC_URL}}multiple-file-list-icon-tiny.png">
{% endif %}
{% if entry.entry.sub_type == 'link' %}
<img src="{{STATIC_URL}}external-link-list-icon-tiny.png">
<img class="no-lead" src="{{STATIC_URL}}external-link-list-icon-tiny.png">
{% endif %}
</a>
</div>
<div class="media-body">
<h4 class="media-heading">
<a href="{{entry.get_absolute_url}}">{{ entry.title}}</a>
Expand All @@ -36,6 +38,6 @@ <h4 class="media-heading">
<li><small>on {{ entry.date_created|date:"d F Y"}}</small></li>
</ul>
</div>
</li>
</div>
<hr> <!--helps to create some space between each submission, draw a line "easily"-->
{% endif %}
3 changes: 2 additions & 1 deletion scipy_central/comments/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class SpcCommentAdmin(CommentsAdmin):
{'fields': ('content_type', 'object_pk', 'site')}
),
(_('Content'),
{'fields': ('user', 'user_name', 'user_email', 'user_url', 'comment', 'rest_comment')}
{'fields': ('user', 'user_name', 'user_email', 'user_url', 'comment',
'rest_comment', 'reputation',)}
),
(_('Metadata'),
{'fields': ('submit_date', 'ip_address', 'is_public', 'is_removed')}
Expand Down
150 changes: 150 additions & 0 deletions scipy_central/comments/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models


class Migration(SchemaMigration):

def forwards(self, orm):
# Adding model 'Comment'
db.create_table('django_comments', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('content_type', self.gf('django.db.models.fields.related.ForeignKey')(related_name='content_type_set_for_comment', to=orm['contenttypes.ContentType'])),
('object_pk', self.gf('django.db.models.fields.TextField')()),
('site', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['sites.Site'])),
('user', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='comment_comments', null=True, to=orm['auth.User'])),
('user_name', self.gf('django.db.models.fields.CharField')(max_length=50, blank=True)),
('user_email', self.gf('django.db.models.fields.EmailField')(max_length=75, blank=True)),
('user_url', self.gf('django.db.models.fields.URLField')(max_length=200, blank=True)),
('comment', self.gf('django.db.models.fields.TextField')(max_length=3000)),
('submit_date', self.gf('django.db.models.fields.DateTimeField')(default=None)),
('ip_address', self.gf('django.db.models.fields.IPAddressField')(max_length=15, null=True, blank=True)),
('is_public', self.gf('django.db.models.fields.BooleanField')(default=True)),
('is_removed', self.gf('django.db.models.fields.BooleanField')(default=False)),
))
db.send_create_signal('comments', ['Comment'])

# Adding model 'CommentFlag'
db.create_table('django_comment_flags', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('user', self.gf('django.db.models.fields.related.ForeignKey')(related_name='comment_flags', to=orm['auth.User'])),
('comment', self.gf('django.db.models.fields.related.ForeignKey')(related_name='flags', to=orm['comments.Comment'])),
('flag', self.gf('django.db.models.fields.CharField')(max_length=30, db_index=True)),
('flag_date', self.gf('django.db.models.fields.DateTimeField')(default=None)),
))
db.send_create_signal('comments', ['CommentFlag'])

# Adding unique constraint on 'CommentFlag', fields ['user', 'comment', 'flag']
db.create_unique('django_comment_flags', ['user_id', 'comment_id', 'flag'])

# Adding model 'SpcComment'
db.create_table('comments_spccomment', (
('comment_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['comments.Comment'], unique=True, primary_key=True)),
('rest_comment', self.gf('django.db.models.fields.TextField')(max_length=3000, null=True)),
))
db.send_create_signal('comments', ['SpcComment'])


def backwards(self, orm):
# Removing unique constraint on 'CommentFlag', fields ['user', 'comment', 'flag']
db.delete_unique('django_comment_flags', ['user_id', 'comment_id', 'flag'])

# Deleting model 'Comment'
db.delete_table('django_comments')

# Deleting model 'CommentFlag'
db.delete_table('django_comment_flags')

# Deleting model 'SpcComment'
db.delete_table('comments_spccomment')


models = {
'auth.group': {
'Meta': {'object_name': 'Group'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
'auth.permission': {
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
'auth.user': {
'Meta': {'object_name': 'User'},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
},
'comments.comment': {
'Meta': {'ordering': "('submit_date',)", 'object_name': 'Comment', 'db_table': "'django_comments'"},
'comment': ('django.db.models.fields.TextField', [], {'max_length': '3000'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'content_type_set_for_comment'", 'to': "orm['contenttypes.ContentType']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'ip_address': ('django.db.models.fields.IPAddressField', [], {'max_length': '15', 'null': 'True', 'blank': 'True'}),
'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'is_removed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'object_pk': ('django.db.models.fields.TextField', [], {}),
'site': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['sites.Site']"}),
'submit_date': ('django.db.models.fields.DateTimeField', [], {'default': 'None'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'comment_comments'", 'null': 'True', 'to': "orm['auth.User']"}),
'user_email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'user_name': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'}),
'user_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'})
},
'comments.commentflag': {
'Meta': {'unique_together': "[('user', 'comment', 'flag')]", 'object_name': 'CommentFlag', 'db_table': "'django_comment_flags'"},
'comment': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'flags'", 'to': "orm['comments.Comment']"}),
'flag': ('django.db.models.fields.CharField', [], {'max_length': '30', 'db_index': 'True'}),
'flag_date': ('django.db.models.fields.DateTimeField', [], {'default': 'None'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'comment_flags'", 'to': "orm['auth.User']"})
},
'comments.spccomment': {
'Meta': {'ordering': "('submit_date',)", 'object_name': 'SpcComment', '_ormbases': ['comments.Comment']},
'comment_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['comments.Comment']", 'unique': 'True', 'primary_key': 'True'}),
'rest_comment': ('django.db.models.fields.TextField', [], {'max_length': '3000', 'null': 'True'})
},
'contenttypes.contenttype': {
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
'sites.site': {
'Meta': {'ordering': "('domain',)", 'object_name': 'Site', 'db_table': "'django_site'"},
'domain': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
'thumbs.thumbs': {
'Meta': {'unique_together': "(('person', 'content_type', 'object_pk'),)", 'object_name': 'Thumbs'},
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'content_type_set_for_thumbs'", 'to': "orm['contenttypes.ContentType']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'ip_address': ('django.db.models.fields.IPAddressField', [], {'max_length': '15'}),
'is_valid': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'object_pk': ('django.db.models.fields.TextField', [], {}),
'person': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}),
'submit_date': ('django.db.models.fields.DateField', [], {'auto_now': 'True', 'blank': 'True'}),
'user_agent': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'vote': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'})
}
}

complete_apps = ['comments']
Loading