Skip to content

Commit

Permalink
markdown integrated | css conflict resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
AtmegaBuzz committed Aug 29, 2023
1 parent 4c997a8 commit 609b621
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 30 deletions.
24 changes: 24 additions & 0 deletions comments/migrations/0006_comment_author_fk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.1 on 2023-08-29 04:22

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
("website", "0080_alter_issue_team_members"),
("comments", "0005_auto_20170727_1309"),
]

operations = [
migrations.AddField(
model_name="comment",
name="author_fk",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="website.userprofile",
),
),
]
3 changes: 2 additions & 1 deletion comments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.db import models
from django.utils import timezone

from website.models import Issue
from website.models import Issue, UserProfile


# Create your models here.
Expand All @@ -13,6 +13,7 @@ class Comment(models.Model):
parent = models.ForeignKey('self', null=True, on_delete=models.CASCADE)
issue = models.ForeignKey(Issue, on_delete=models.CASCADE, related_name='comments')
author = models.CharField(max_length=200)
author_fk = models.ForeignKey(UserProfile,null=True,on_delete=models.SET_NULL)
author_url = models.CharField(max_length=200)
text = models.TextField()
created_date = models.DateTimeField(default=timezone.now)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = ["Your Name <you@example.com>"]
license = "AGPLv3"

[tool.poetry.dependencies]
python = "3.11.2"
python = "3.11.3"
toml = "^0.10.2"
Django = "^4.0.5"
dj-database-url = "^1.0.0"
Expand Down
22 changes: 22 additions & 0 deletions website/migrations/0080_alter_issue_team_members.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.1 on 2023-08-29 04:22

from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("website", "0079_userprofile_crypto_address_and_more"),
]

operations = [
migrations.AlterField(
model_name="issue",
name="team_members",
field=models.ManyToManyField(
blank=True, related_name="reportmembers", to=settings.AUTH_USER_MODEL
),
),
]
2 changes: 1 addition & 1 deletion website/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class Issue(models.Model):
(7, "Server Down"),
)
user = models.ForeignKey(User, null=True, blank=True, on_delete=models.CASCADE)
team_members = models.ManyToManyField(User,related_name="reportmembers",null=True,blank=True)
team_members = models.ManyToManyField(User,related_name="reportmembers",blank=True)
hunt = models.ForeignKey(Hunt, null=True, blank=True, on_delete=models.CASCADE)
domain = models.ForeignKey(Domain, null=True, blank=True, on_delete=models.CASCADE)
url = models.URLField()
Expand Down
2 changes: 1 addition & 1 deletion website/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<script src="{% static 'js/text-slider.js' %}"></script>
<!-- <script src="{% static "js/embed.js" %}"></script> -->
<script src="https://cdn.tailwindcss.com"></script>

{% block head %}
{% endblock %}

Expand Down
21 changes: 16 additions & 5 deletions website/templates/comments2.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{% load static %}

<section id="comment_root" class="not-format mt-10">
<div class="flex justify-between items-center mb-6">
<h2 class="text-xl lg:text-3xl font-bold text-gray-900 ">Comments ({{ all_comment | length }})</h2>
Expand Down Expand Up @@ -30,11 +32,20 @@ <h2 class="text-xl lg:text-3xl font-bold text-gray-900 ">Comments ({{ all_commen
<footer class="flex justify-between items-center mb-2">
<div class="flex items-center">
<p class="inline-flex items-center mr-3 text-3xl text-gray-900 ">
<img
class="mr-2 w-12 h-12 rounded-full"
src="{{ MEDIA_URL }}{{ user.userprofile.user_avatar }}"
alt="Michael Gough">
{{ comment.author }}
{% if comment.author_fk %}

<img
class="mr-2 w-12 h-12 rounded-full"
src="{{ MEDIA_URL }}{{ comment.author_fk.user_avatar }}"
alt="{{ comment.author }} profile">

{% else %}
<img
class="mr-2 w-12 h-12 rounded-full"
src="{% static 'images/dummy-user.png' %}"
alt="User profile">
{% endif %}
{{ comment.author }} {{ comment.author_url }}
</p>
<p class="text-2xl text-gray-600 "><time pubdate datetime="2022-02-08"
title="February 8th, 2022">commented {{ comment.created_date | timesince }} ago</time></p>
Expand Down
27 changes: 11 additions & 16 deletions website/templates/issue2.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,15 @@
{% endif %}
</div>

<template id="bug_report_template">
<style>
/* Local styles here */
</style>
<!-- Local HTML content here -->
</template>

<div id="bug_report" class="w-full flex flex-col">
<style>
.reset-style * {
all: revert;
}
.reset-style img{
max-width: 100%;
}
</style>
<div id="bug_report" class="reset-style">

</div>
</div>
Expand Down Expand Up @@ -262,20 +263,14 @@ <h2 class="mb-2 text-xl font-bold leading-tight text-gray-900 ">

<script>


const template = document.querySelector('#bug_report_template');
const shadowRoot = document.querySelector('#bug_report').attachShadow({ mode: 'open' });
shadowRoot.appendChild(template.content.cloneNode(true));
const contentContainer = shadowRoot.querySelector('#bug_report'); // Assuming a container class


const md = window.markdownit();
const markdownContent = `{{ object.markdown_description|escapejs }}`;
const renderedHtml = md.render(markdownContent);
// const renderedHtml = parse(markdownContent);
// const renderedHtml = marked.parse(markdownContent)
contentContainer.innerHTML = renderedHtml;

// $("#bug_report").html(renderedHtml);
$("#bug_report").html(renderedHtml);


function subscribe_domain(){
Expand Down
8 changes: 3 additions & 5 deletions website/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1986,13 +1986,9 @@ def get_score(request):

def comment_on_issue(request, issue_pk):


issue = Issue.objects.filter(pk=issue_pk).first()

if request.method == "POST":

if not isinstance(request.user,User):
return redirect("/accounts/login")
if request.method == "POST" and isinstance(request.user,User):

comment = request.POST.get("comment","")
replying_to_input = request.POST.get("replying_to_input","").split("#")
Expand All @@ -2014,6 +2010,7 @@ def comment_on_issue(request, issue_pk):
parent = parent_comment,
issue = issue,
author = request.user.username,
author_fk = request.user.userprofile,
author_url = f"profile/{request.user.username}/",
text = comment
)
Expand All @@ -2022,6 +2019,7 @@ def comment_on_issue(request, issue_pk):
Comment.objects.create(
issue = issue,
author = request.user.username,
author_fk = request.user.userprofile,
author_url = f"profile/{request.user.username}/",
text = comment
)
Expand Down

0 comments on commit 609b621

Please sign in to comment.