Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time Tracking Task #3

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,7 @@ dmypy.json

# Pyre type checker
.pyre/


# PyCharm
.idea
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:3.8.5-alpine3.12
MAINTAINER Mo'ath Zaghdad

ENV PYTHONUNBUFFERD 1

COPY ./requirements.txt /requirements.txt
RUN pip install -r /requirements.txt
RUN apk --no-cache add gettext

RUN mkdir -p /app
WORKDIR /app
COPY ./app /app

RUN adduser -D user
USER user
Moath-Zaghdad marked this conversation as resolved.
Show resolved Hide resolved
14 changes: 14 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
flake8 = "*"

[packages]
django = "~=3.1"
djangorestframework = "~=3.11.1"

[requires]
python_version = "3.8"
92 changes: 92 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
# task-012
# task-012


# Setup
```bash
docker-compose build
docker-compose run --rm app sh -c "python manage.py migrate"
docker-compose run --rm app sh -c "python manage.py loaddata fixtures/users.json"
docker-compose run --rm app sh -c "python manage.py compilemessages"
docker-compose run --rm app sh -c "python manage.py test && flake8" # run the tests and flake8
docker-compose up
```
6 changes: 6 additions & 0 deletions app/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[flake8]
exclude =
migrations,
__pycache__,
manage.py,
settings.py
92 changes: 92 additions & 0 deletions app/fixtures/users.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
[
{
"model": "auth.user",
"pk": 1,
"fields": {
"password": "pbkdf2_sha256$216000$F0dlaJuv7AsL$duDS6o1yMmazBQnnOZLVU3NMLWzHB9pcCyjI9Dcav+4=",
"last_login": null,
"is_superuser": true,
"username": "admin",
"first_name": "",
"last_name": "",
"email": "[email protected]",
"is_staff": true,
"is_active": true,
"date_joined": "2020-08-06T12:10:24.399Z",
"groups": [],
"user_permissions": []
}
},
{
"model": "auth.user",
"pk": 2,
"fields": {
"password": "pbkdf2_sha256$180000$7pqm6zAaWmCe$l7cCgbICilx5kz8LHJ5xh0g1Zx1Q+xuRkFh8fx8AnZI=",
"last_login": null,
"is_superuser": false,
"username": "waseem",
"first_name": "",
"last_name": "",
"email": "[email protected]",
"is_staff": false,
"is_active": true,
"date_joined": "2020-08-06T12:10:24.399Z",
"groups": [],
"user_permissions": []
}
},
{
"model": "auth.user",
"pk": 3,
"fields": {
"password": "pbkdf2_sha256$180000$htF9zN6ud9Fr$NCqkFGNoc/zcfJuSpTO3HDjq7GowV/TuwnYde73X3m0=",
"last_login": null,
"is_superuser": false,
"username": "motasem",
"first_name": "",
"last_name": "",
"email": "[email protected]",
"is_staff": false,
"is_active": true,
"date_joined": "2020-08-06T12:10:24.399Z",
"groups": [],
"user_permissions": []
}
},
{
"model": "auth.user",
"pk": 4,
"fields": {
"password": "pbkdf2_sha256$180000$33CjJbgsof0J$2/m9gv/36qRfgS7ZAwgMsEq2UFLy2mfVjAABdYOrWDA=",
"last_login": null,
"is_superuser": false,
"username": "ayman",
"first_name": "",
"last_name": "",
"email": "[email protected]",
"is_staff": false,
"is_active": true,
"date_joined": "2020-08-06T12:10:24.399Z",
"groups": [],
"user_permissions": []
}
},
{
"model": "auth.user",
"pk": 5,
"fields": {
"password": "pbkdf2_sha256$180000$A0MgsVEXpfMN$t5fo3EnchdIFTUFnkryDAk/Uwl3lYt5VUbiCF9IYzzU=",
"last_login": null,
"is_superuser": false,
"username": "moath",
"first_name": "",
"last_name": "",
"email": "[email protected]",
"is_staff": false,
"is_active": true,
"date_joined": "2020-08-06T12:10:24.399Z",
"groups": [],
"user_permissions": []
}
}
]
28 changes: 28 additions & 0 deletions app/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-08-08 22:31+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#: time_tracking/vacation/views.py:45
msgid "Reached max vacations days"
msgstr "Sorry, you already reached the max vacations days a year."

#: time_tracking/vacation/views.py:53
#, python-format
msgid "Can't add more than %(days)s"
msgstr "Sorry, you can't add more than %(days)s day."
21 changes: 21 additions & 0 deletions app/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'time_tracking.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)


if __name__ == '__main__':
main()
Empty file added app/time_tracking/__init__.py
Empty file.
16 changes: 16 additions & 0 deletions app/time_tracking/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for time_tracking project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'time_tracking.settings')

application = get_asgi_application()
Empty file.
5 changes: 5 additions & 0 deletions app/time_tracking/event/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.contrib import admin

from time_tracking.event.models import Event

admin.site.register(Event)
5 changes: 5 additions & 0 deletions app/time_tracking/event/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class EventConfig(AppConfig):
name = 'event'
27 changes: 27 additions & 0 deletions app/time_tracking/event/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 3.1 on 2020-08-06 13:31

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Event',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=120)),
('description', models.TextField(blank=True, null=True)),
('start_time', models.DateTimeField()),
('end_time', models.DateTimeField()),
],
options={
'ordering': ['-start_time'],
},
),
]
Loading