Skip to content

Commit

Permalink
Finally reworked the pointer and added button for mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
awallenfang committed Dec 7, 2024
1 parent 972d0de commit 743b994
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 30 deletions.
2 changes: 1 addition & 1 deletion debug_startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ echo "Creating superuser"
python manage.py createsuperuser --noinput

echo "Starting Django application"
python manage.py runserver 0.0.0.0:42069
python manage.py runserver 0.0.0.0:5000
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ services:
- "5432:5432"
web:
build: .
# command: python manage.py runserver 0.0.0.0:42069
# command: python manage.py runserver 0.0.0.0:5000
entrypoint: bash debug_startup.sh
volumes:
- .:/code
ports:
- "42069:42069"
- "5000:5000"
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
Expand All @@ -27,4 +27,4 @@ services:
- [email protected]
- DJANGO_SUPERUSER_PASSWORD=admin
depends_on:
- db
- db
11 changes: 7 additions & 4 deletions hub/static/hub/base.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
* {
--light: rgba(244,250,255,1);
--light: rgba(244, 250, 255, 1);
--light-bg: #DEE3E1;
--mid-bg: #b7c5c3;
--dark-bg: #303935;
--text: #191710;
--strong-highlight: rgba(53,255,146,1);
--strong-highlight: rgba(53, 255, 146, 1);
--light-highlight: #90FFD1;
--error-bg: #ff3c3c;
--negative-bg: #ebbbbb;
Expand Down Expand Up @@ -74,6 +74,8 @@ header {
padding: 0.5rem;
margin: 0.2rem;
max-height: 2.2rem;
font-size: small;
text-align: center;
}

/* Drop down menus */
Expand All @@ -90,12 +92,13 @@ header {
background-color: var(--light-bg);
width: 100%;
border-radius: 0.25rem;
padding: 1rem;;
padding: 1rem;
;
}

.dropdown-open {
display: block;

}

.dropdown-closed {
Expand Down
34 changes: 22 additions & 12 deletions todos/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,26 @@ def get_full_order(self):
ordered_users = OrderedUser.objects.filter(recurrent_todo = self).order_by("order")
return [ou.user for ou in ordered_users]

def get_rotation_at_date(self, check_date:datetime):
users = OrderedUser.objects.filter(recurrent_todo = self)
if len(users) == 0:
return -1
# def get_rotation_at_date(self, check_date:date):
# users = OrderedUser.objects.filter(recurrent_todo = self)
# if len(users) == 0:
# return -1

start_time = self.started_at
# start_time = self.started_at

passed_days = (check_date - date(start_time.year, start_time.month, start_time.day)).days
return (passed_days // self.day_rotation) % len(users)
# passed_days = (check_date - date(start_time.year, start_time.month, start_time.day)).days
# return (passed_days // self.day_rotation) % len(users)

def get_current_rotation(self):
"""
Returns the current index of the user that is assigned to the todo
Returns -1 if there are no users
"""
current_time = localtime(now()).date()

return self.get_rotation_at_date(current_time)
if len(self.assigned_users.all()) > 0:
self.tick_rotation()
return self.recurrency_turn

return -1

def remove_position(self, position):
ordered_users = OrderedUser.objects.filter(recurrent_todo = self).order_by("order")
Expand All @@ -97,6 +99,8 @@ def remove_position(self, position):
ord_usr.order = i
ord_usr.save()

self.recurrency_turn = self.recurrency_turn % len(self.assigned_users.all())

def reorder_user(self, prev_pos, new_pos):
ordered_users = OrderedUser.objects.filter(recurrent_todo = self).order_by("order")

Expand All @@ -110,10 +114,16 @@ def reorder_user(self, prev_pos, new_pos):
for i, ord_usr in enumerate(ordered_users):
ord_usr.order = i
ord_usr.save()



def tick_rotation(self):
date_now = datetime.now().date()
last_date = self.last_check.date()
if datetime.now().date() > self.last_check.date():
day_difference = (date_now - last_date).days

if day_difference > 0:
self.recurrency_turn += day_difference % len(self.assigned_users.all())
self.last_check = datetime.now()

#######

Expand Down
20 changes: 10 additions & 10 deletions todos/static/todos/todos.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/* ############### General todo view ############### */
#todo-block {
display: flex;
Expand All @@ -17,6 +16,7 @@
justify-items: center;
padding: 0.5rem;
width: 25vw;
min-width: 20rem;
background-color: var(--light-bg);
justify-content: space-between;
border-radius: 0.5rem;
Expand Down Expand Up @@ -86,7 +86,7 @@ main {
align-items: center;
}

h2 {
h2 {
margin-bottom: 0.5rem;
margin-top: 0.5rem;
}
Expand Down Expand Up @@ -132,7 +132,7 @@ textarea {
padding: 1rem;
height: 100%;
gap: 0.5rem;

}

.recurrency-settings {
Expand Down Expand Up @@ -192,19 +192,19 @@ textarea {
z-index: 1;
position: absolute;
left: 50%;
transform: translate(-50%, 0);
transform: translate(-50%, 0);
width: 35vw;
height: 25vw;
display:flex;
display: flex;
flex-direction: column;
background-color: var(--light-bg);
padding: 0.5rem;
border-radius: 0.5rem;
-webkit-box-shadow: 5px 5px 15px -5px rgba(0,0,0,0.88);
box-shadow: 5px 5px 15px -5px rgba(0,0,0,0.88);
-webkit-box-shadow: 5px 5px 15px -5px rgba(0, 0, 0, 0.88);
box-shadow: 5px 5px 15px -5px rgba(0, 0, 0, 0.88);
}

.close-icon-container {
.close-icon-container {
cursor: pointer;
}

Expand All @@ -220,7 +220,7 @@ textarea {
}

.recurrency-item-container {
display:flex;
display: flex;
flex-direction: row;
align-items: center;
width: 100%;
Expand All @@ -246,5 +246,5 @@ textarea {
}

.recurrent_refresh_icon {
filter:opacity(50%);
filter: opacity(50%);
}
9 changes: 9 additions & 0 deletions todos/templates/todos/components/todo.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
{%if todo.assigned_user is not None%}
<p>{{todo.assigned_user.auth_user.username}}</p>
{%endif%}
{% if not todo.done %}
<a class="button btn-small"
hx-post="{% url 'todos:close_todo' todo.id %}"
hx-target="#todo-list">Done</a>
{% else %}
<a class="button btn-small"
hx-post="{% url 'todos:open_todo' todo.id %}"
hx-target="#todo-list">Reopen</a>
{% endif %}
</div>
<div class="todo-buttons">
<button class="dropdown-button" onclick="toggleDropdown(event)">...</button>
Expand Down

0 comments on commit 743b994

Please sign in to comment.