Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
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
5 changes: 5 additions & 0 deletions bugheist/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
InboundParseWebhookView,
LeaderboardView,
LeaderboardApiViewSet,
MonthlyLeaderboardView,
IssueView,
AllIssuesView,
SpecificIssuesView,
Expand Down Expand Up @@ -256,6 +257,9 @@
re_path(
r"^like_issue/(?P<issue_pk>\d+)/$", website.views.like_issue, name="like_issue"
),
re_path(
r"^spam_issue/(?P<issue_pk>\d+)/$", website.views.spam_issue, name="spam_issue"
),
re_path(
r"^save_issue/(?P<issue_pk>\d+)/$", website.views.save_issue, name="save_issue"
),
Expand All @@ -271,6 +275,7 @@
re_path(r"^all_activity/$", AllIssuesView.as_view(), name="all_activity"),
re_path(r"^label_activity/$", SpecificIssuesView.as_view(), name="all_activity"),
re_path(r"^leaderboard/$", LeaderboardView.as_view(), name="leaderboard"),
re_path(r"^leaderboard/monthly/$", MonthlyLeaderboardView.as_view(), name="leaderboard_monthly"),
re_path(r"^leaderboard/api/$", LeaderboardApiViewSet.as_view(), name="leaderboard_api"),
re_path(r"^scoreboard/$", ScoreboardView.as_view(), name="scoreboard"),
re_path(r"^issue/$", IssueCreate.as_view(), name="issue"),
Expand Down
20 changes: 20 additions & 0 deletions website/migrations/0069_userprofile_issue_spamed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.1 on 2022-08-18 14:34

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("website", "0068_winner_hunt"),
]

operations = [
migrations.AddField(
model_name="userprofile",
name="issue_spamed",
field=models.ManyToManyField(
blank=True, related_name="spamed", to="website.issue"
),
),
]
1 change: 1 addition & 0 deletions website/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ class UserProfile(models.Model):
max_digits=10, decimal_places=2, null=True, blank=True
)
issue_upvoted = models.ManyToManyField(Issue, blank=True, related_name="upvoted")
issue_spamed = models.ManyToManyField(Issue,blank=True,related_name="spamed")
issue_saved = models.ManyToManyField(Issue, blank=True, related_name="saved")

def avatar(self, size=36):
Expand Down
25 changes: 25 additions & 0 deletions website/templates/_spams.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{% load gravatar %}
<a class="btn btn-info btn-xs spam_unspam" name="{{ object.pk }}">
<i class="fa fa-thumbs-down"></i> Spam {{ spams }}
</a>


<div id="spamedBy" class="modal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<h3>Spamed by:</h3>
{% for usr in spamers %}
<div class="list-group-item">
{% if usr.user.socialaccount_set.all.0.get_avatar_url %}
<img src="{{ usr.user.socialaccount_set.all.0.get_avatar_url }}" height="50px">
{% else %}
<img src="{% gravatar_url usr.user.email 50 %}">
{% endif %}
<a href="/profile/{{ usr.user.username }}">{{ usr.user.username }}</a>
</div>
{% endfor %}
</div>
</div>
</div>
</div>
26 changes: 21 additions & 5 deletions website/templates/issue.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@
}

.like_btn,
.spam_btn
.bookmark,
.copy-btn,
.spam_btn a.spamed-by
.like_btn a.liked-by {
vertical-align: top;
}
Expand Down Expand Up @@ -152,6 +154,9 @@ <h3 class="page-header">
<span class="like_btn">
{% include '_likes.html' %}
</span>
<span class="spam_btn">
{% include '_spams.html' %}
</span>
<a class="bookmark btn btn-success btn-xs" name="{{ object.pk }}">
<i class="fa fa-bookmark-o"></i> Bookmark
</a>
Expand Down Expand Up @@ -354,11 +359,8 @@ <h3>Comments:</h3>
</div>

<script type="text/javascript">
var label = {
{
object.label
}
};
var label = "{{object.label}}";

$(document).on('click', '.edit-issue', function (e) {
$('.form input[name=description]').val($('.issue-desc').text());
$('.form input[name=domain]').val($('.issue-domain').text());
Expand Down Expand Up @@ -487,6 +489,20 @@ <h3>Comments:</h3>
});
});

$('body').on('click', '.spam_unspam', function (e) {
e.preventDefault();
var issue_pk = $(this).attr('name');
$.ajax({
type: 'GET',
url: '/spam_issue/' + issue_pk + '/',
data: {},
success: function (data) {
$('.spam_btn').html(data);
},
});
});


$('body').on('click', '.bookmark', function (e) {
e.preventDefault();
var issue_pk = $(this).attr('name');
Expand Down
46 changes: 25 additions & 21 deletions website/templates/leaderboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,37 @@

{% block content %}
<div class="row">
<div class="col-lg-6">
<h1 class="page-header">Global Leaderboard</h1>
<div class="col-lg-6" style="display: flex; justify-content: center; align-items: center;">
<h1 class="page-header">Global Leaderboard</h1>
</div>
</div>
<div class="row">
<div class="col-lg-9">
<div class="list-group">
{% for leader in leaderboard %}
<div class="list-group-item">
{% if leader.userprofile.avatar %}
<img src="{{ leader.userprofile.avatar }}" class="img-responsive img-thumbnail profileimage">
{% elif leader.socialaccount_set.all.0.get_avatar_url %}
<img src="{{ leader.socialaccount_set.all.0.get_avatar_url }}" class="profileimage">
{% else %}
<img src="{% gravatar_url leader.email 50 %}" class="profileimage">
{% endif %}
<a href="/profile/{{ leader.username }}">{{ leader.username }}</a>
<span class="pull-right badge">{{ leader.total_score }} Points</span>
{% if leader.userprofile.winnings %}
<span class="pull-right badge">${{ leader.userprofile.winnings|default:""|floatformat }}</span>
{% endif %}
{%if not leaderboard%}
<p style="color: red;">No data for this month</p>
{%else%}
{% for leader in leaderboard %}
<div class="list-group-item">
{% if leader.userprofile.avatar %}
<img src="{{ leader.userprofile.avatar }}" class="img-responsive img-thumbnail profileimage">
{% elif leader.socialaccount_set.all.0.get_avatar_url %}
<img src="{{ leader.socialaccount_set.all.0.get_avatar_url }}" class="profileimage">
{% else %}
<img src="{% gravatar_url leader.email 50 %}" class="profileimage">
{% endif %}
<a href="/profile/{{ leader.username }}">{{ leader.username }}</a>
<span class="pull-right badge">{{ leader.total_score }} Points</span>
{% if leader.userprofile.winnings %}
<span class="pull-right badge">${{ leader.userprofile.winnings|default:""|floatformat }}</span>
{% endif %}

<span><kbd
class="{{ leader.userprofile.get_title_display }} titleuser">{{ leader.userprofile.get_title_display }}</kbd></span>
</div>
{% endfor %}
<span><kbd
class="{{ leader.userprofile.get_title_display }} titleuser">{{ leader.userprofile.get_title_display }}</kbd></span>
</div>
{% endfor %}
{%endif%}
</div>
</div>
</div>
{% endblock %}
{% endblock %}
Loading