-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
203 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
totem/users/migrations/0021_user_profile_avatar_seed_user_profile_avatar_type.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 4.2.5 on 2023-10-12 21:17 | ||
|
||
from django.db import migrations, models | ||
import uuid | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("users", "0020_alter_user_profile_image"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="user", | ||
name="profile_avatar_seed", | ||
field=models.UUIDField(default=uuid.uuid4), | ||
), | ||
migrations.AddField( | ||
model_name="user", | ||
name="profile_avatar_type", | ||
field=models.CharField(choices=[("TD", "Tie Dye"), ("IM", "Image")], default="TD", max_length=2), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
{% extends "users/profile_base.html" %} | ||
{% load static %} | ||
{% load avatar %} | ||
{% block profile_content %} | ||
<div> | ||
<h2 class="h2 pb-10">Edit Profile Image</h2> | ||
<div class="hx-profile-image-form bg-white rounded-box p-4 inline-flex flex-col justify-center items-center m-auto transition-all duration-300" | ||
hx-select=".hx-profile-image-form" | ||
hx-swap="outerHTML" | ||
hx-target="this"> | ||
<script> | ||
function profile_randomize() { | ||
document.getElementsByName("randomize")[0].click(); | ||
} | ||
function profile_upload() { | ||
const pimage = document.getElementsByName("profile_image")[0]; | ||
pimage.onchange = function() { | ||
pimage.form.submit(); | ||
} | ||
pimage.click(); | ||
} | ||
function profile_action() { | ||
{% if user.profile_avatar_type == "IM" %} | ||
profile_upload(); | ||
{% elif user.profile_avatar_type == "TD" %} | ||
profile_randomize(); | ||
{% endif %} | ||
} | ||
</script> | ||
<div class="relative inline-block cursor-pointer mb-5" | ||
onclick="profile_action()"> | ||
{% avatar user=request.user blank_ok=True %} | ||
<div class="opacity-0 rounded-full w-full h-full bg-tcreme hover:opacity-100 transition-opacity absolute top-0 left-0 bg-opacity-70"> | ||
{% if user.profile_avatar_type == "IM" %} | ||
<h3 class="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2">Upload</h3> | ||
{% elif user.profile_avatar_type == "TD" %} | ||
<h3 class="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2">Randomize</h3> | ||
{% endif %} | ||
</div> | ||
<div class="absolute bottom-2 rounded-full bg-white p-1 right-2"> | ||
{% if user.profile_avatar_type == "IM" %} | ||
<svg width="25" | ||
class="absolute bottom-0 rounded-full bg-white p-1 right-0" | ||
height="25" | ||
viewBox="0 0 24 24" | ||
xmlns="http://www.w3.org/2000/svg"> | ||
<path fill="#000000" d="M11 16V7.85l-2.6 2.6L7 9l5-5l5 5l-1.4 1.45l-2.6-2.6V16h-2Zm-5 4q-.825 0-1.413-.588T4 18v-3h2v3h12v-3h2v3q0 .825-.588 1.413T18 20H6Z" /> | ||
</svg> | ||
{% elif user.profile_avatar_type == "TD" %} | ||
<svg width="25" | ||
class="absolute bottom-0 rounded-full bg-tcreme p-1 right-0" | ||
height="25" | ||
viewBox="0 0 512 512" | ||
xmlns="http://www.w3.org/2000/svg"> | ||
<path fill="#000000" d="M341.3 28.3v85.3H128c-70.7 0-128 57.3-128 128c0 21.5 5.8 41.4 15.2 59.2L68 263.2c-2.4-6.8-4-13.9-4-21.5c0-35.4 28.7-64 64-64h213.3V263L512 156.3V135L341.3 28.3zM444 262.8c2.4 6.8 4 13.9 4 21.5c0 35.4-28.6 64-64 64H170.7V263L0 369.7V391l170.7 106.7v-85.3H384c70.7 0 128-57.3 128-128c0-21.5-5.8-41.4-15.2-59.2L444 262.8z" /> | ||
</svg> | ||
{% endif %} | ||
</div> | ||
</div> | ||
<div> | ||
<form hx-post="{% url "users:profile-image" %}" | ||
action="{% url "users:profile-image" %}" | ||
method="post" | ||
enctype="multipart/form-data"> | ||
{% csrf_token %} | ||
<button type="submit" class="hidden" name="randomize" value="true"></button> | ||
<input type="file" | ||
class="hidden" | ||
name="profile_image" | ||
accept="image/png, image/jpeg"> | ||
<div class="tabs tabs-boxed inline-block"> | ||
{% for choice in form.fields.profile_avatar_type.choices %} | ||
<button type="submit" | ||
name="profile_avatar_type" | ||
value="{{ choice.0 }}" | ||
class="tab {% if choice.0 == user.profile_avatar_type %}tab-active{% endif %}"> | ||
{{ choice.1 }} | ||
</button> | ||
{% endfor %} | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock profile_content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters