Skip to content

Commit

Permalink
feat: minor version update (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
MagneticNeedle authored Oct 16, 2022
2 parents 603901c + 063e2b0 commit 28cdbb8
Show file tree
Hide file tree
Showing 12 changed files with 349 additions and 135 deletions.
48 changes: 47 additions & 1 deletion bfportal/bfportal/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@

<meta name="viewport" content="width=device-width, initial-scale=1"/>
{% block preload_media %}{% endblock %}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.13.2/themes/base/jquery-ui.min.css" integrity="sha512-ELV+xyi8IhEApPS/pSj66+Jiw+sOT1Mqkzlh8ExXihe4zfqbWkxPRi8wptXIO9g73FSlhmquFlUOuMSoXz5IRw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.13.2/themes/base/theme.min.css" integrity="sha512-hbs/7O+vqWZS49DulqH1n2lVtu63t3c3MTAn0oYMINS5aT8eIAbJGDXgLt6IxDHcWyzVTgf9XyzZ9iWyVQ7mCQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
{% block extra_css %}
{# Override this in templates to add extra stylesheets #}
{% endblock %}
Expand Down Expand Up @@ -95,11 +97,12 @@
</head>

<body class="bg-bg-default min-h-screen m-0 relative flex flex-col {% block body_class %}{% endblock %}">
<div id="popUpBackground" class="fixed w-screen h-screen bg-default/[.95] z-[1] hidden" onclick="hidePopUps()"></div>
{% block header %}
{% include nav_tmpl|default:'navbar.html' %}
{% endblock %}

<div id="main" class="main-content flex flex-col flex-grow gap-y-12 overflow-x-hidden">
<div id="main" class="main-content flex flex-col flex-grow gap-y-12 overflow-x-hidden mb-8">

{% block extra_content %}
{% include_block page.extra_content %}
Expand All @@ -126,6 +129,7 @@
<script src="{% static 'js/jquery.min.js' %}"
integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.13.2/jquery-ui.min.js" integrity="sha512-57oZ/vW8ANMjR/KQ6Be9v/+/h6bq9/l3f0Oc7vn6qMqyhvPd1cvKBRWWpzu0QoneImqr2SkmO4MSqU+RpHom3Q==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js"
integrity="sha512-z4OUqw38qNLpn1libAN9BsoDx6nbNFio5lA6CuTp9NlK83b89hgyCVq+N5FdBJptINztxn1Z3SaKSKUS5UP60Q=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
Expand Down Expand Up @@ -239,6 +243,48 @@
})
}
)
async function copyDivToClipboard(elem) {
const container_div = $(elem);
if (container_div.attr('data-copy-state') === "normal"){ // only run when the inner html is set correctly
const old_html = container_div.html(),
state_class = "bg-bf2042-5 hover:bg-bf2042-5";

container_div.attr('data-copy-state', "copy");
await navigator.clipboard.writeText(container_div.attr('data-copy')).then(
() =>{
container_div.addClass(state_class);
container_div.text("Copied")
setTimeout(function () {
container_div.fadeOut(200, function () {
container_div.html(old_html).fadeIn(1000);
container_div.attr('data-copy-state', "normal")
})
container_div.removeClass(state_class);
}, 1000);
}, () => {
console.log("Copy Failed");
container_div.attr('data-copy-state', "normal")
}
)
}
}
document.addEventListener('keydown', function(e) {
if(e.key === "Escape"){
hidePopUps();
}
});
function hidePopUps() {
$('#popUpBackground, .popup').fadeOut(100)
}
function showPopUp(id) {
const popup = $(document.getElementById(id))
if (popup) {
$(`#popUpBackground`).fadeIn(100);
popup.fadeIn();
popup.css('display', 'flex');
}
}

</script>
{% block extra_js %}
{# Override this in templates to add extra javascript #}
Expand Down
4 changes: 1 addition & 3 deletions bfportal/bfportal/templates/footer.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{% load static %}
<div class="footer {% if request.path != "/" %}sticky bottom-0{% endif %} mt-auto flex cursor-default flex-col w-full bg-card-bg justify-center align-middle text-center drop-shadow-lg py-2 mt-4">
<div>
<div class="footer {% if request.path != "/" %}sticky bottom-0{% endif %} mt-auto flex cursor-default flex-col w-full bg-card-bg justify-center align-middle text-center drop-shadow-lg py-2">
<div class="flex flex-row flex-wrap gap-x-1 gap-y-1 items-center justify-center text-white text-sm">
{% with 14 as icon_width %}

Expand Down Expand Up @@ -35,7 +34,6 @@
</a>
{% endwith %}
</div>
</div>
</div>
<script>
function randomIntFromInterval(min, max) { // min and max included
Expand Down
6 changes: 6 additions & 0 deletions bfportal/core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ class Meta:
"vid_url",
]

def clean_category(self):
"""Called when category field is being validated"""
if self.cleaned_data.get("category", None) is None:
raise forms.ValidationError("Must provide at least one category")
return self.cleaned_data["category"]

def clean_code(self):
"""Called when code field is being validated"""
code = self.cleaned_data["code"]
Expand Down
12 changes: 6 additions & 6 deletions bfportal/core/management/commands/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ async def fetch(session, page: ExperiencePage, url: str):
"""Checks GT api if an experience is valid or not"""
async with session.get(url) as response:
if response.status == 404:
logger.debug(f"{page} is bugged....")
page.bugged = True
logger.debug(f"{page} is broken....")
page.broken = True
else:
json: dict = await response.json()
if json.get("originalPlayground", False):
if page.bugged:
logger.debug(f"{page} was bugged now fixed....")
page.bugged = False
if page.broken:
logger.debug(f"{page} was broken now fixed....")
page.broken = False
else:
page.bugged = True
page.broken = True

await sync_to_async(page.save, thread_sensitive=True)()

Expand Down
33 changes: 31 additions & 2 deletions bfportal/core/models/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from .pages import CustomBasePage


def social_user(discord_id: int):
def social_user(discord_id: int) -> User | bool:
"""Returns a User object for a discord id"""
try:
usr = get_user_model().objects.get(
Expand Down Expand Up @@ -162,4 +162,33 @@ def user_experiences(self, request, discord_id):
self.get_context(request=request, list_experiences=True, user=user),
)
else:
return HttpResponse("User not Found", status=404)
return TemplateResponse(request, "404.html", status=404)

@route(r"(\d{18})/liked/$", name="discord_id")
def user_liked_experiences(self, request, discord_id):
"""Servers a list of experiences by a user"""
user = social_user(discord_id=discord_id)
if user:
return TemplateResponse(
request,
"core/experiences_page.html",
{"posts": user.profile.liked.all()},
)
else:
return TemplateResponse(request, "404.html", status=404)

@route(r"^(\w+)/$", name="username")
def named_profile_page_view(self, request: HttpRequest, username):
"""Handles the requests for users that have a named profile"""
if username == "admin":
return TemplateResponse(
request,
self.get_template(request),
self.get_context(
request,
list_experiences=True,
user=User.objects.filter(is_superuser=True).first(),
),
)
else:
return TemplateResponse(request, "404.html", status=404)
Loading

0 comments on commit 28cdbb8

Please sign in to comment.