First version

This commit is contained in:
2020-05-13 15:54:40 +02:00
parent b26ed98cd4
commit a4c55565ec
69 changed files with 2899 additions and 0 deletions

View File

@ -0,0 +1 @@
default_app_config = 'apps.employee.apps.EmployeeConfig'

View File

@ -0,0 +1,20 @@
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.contrib.auth.models import User
from .models import Employee
# Define an inline admin descriptor for Employee model
# which acts a bit like a singleton
class EmployeeInline(admin.StackedInline):
model = Employee
can_delete = False
verbose_name_plural = 'employee'
# Define a new User admin
class UserAdmin(BaseUserAdmin):
inlines = (EmployeeInline,)
# Re-register UserAdmin
admin.site.unregister(User)
admin.site.register(User, UserAdmin)

View File

@ -0,0 +1,8 @@
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _
class EmployeeConfig(AppConfig):
name = 'apps.employee'
label = 'employee'
verbose_name = _('Employee')
verbose_name_plural = _('Employees')

View File

@ -0,0 +1,34 @@
# Generated by Django 3.0.6 on 2020-05-13 13:33
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('polyclinic', '0001_initial'),
('hospital', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Employee',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_at', models.DateTimeField(auto_now_add=True, help_text='The date and time this model has been created', verbose_name='Date created')),
('updated_at', models.DateTimeField(auto_now=True, help_text='The date and time this model has been updated', verbose_name='Date updated')),
('phone', models.CharField(blank=True, help_text='The direct phone number of this employee', max_length=15, verbose_name='Phone number')),
('hospital', models.ForeignKey(help_text='Select the hospital for this employee', on_delete=django.db.models.deletion.CASCADE, to='hospital.Hospital')),
('polyclinic', models.ManyToManyField(blank=True, help_text='Select the polyclinic(s) for this employee', to='polyclinic.Polyclinic')),
('user', models.OneToOneField(help_text='Django user', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
'abstract': False,
},
),
]

View File

@ -0,0 +1,20 @@
from django.db import models
from django.contrib.auth.models import User
from django.utils.translation import gettext_lazy as _
from lib.models.base import MetaDataModel
from apps.hospital.models import Hospital
from apps.polyclinic.models import Polyclinic
# Create your models here.
class Employee(MetaDataModel):
user = models.OneToOneField(User, on_delete=models.CASCADE, help_text=_('Django user'))
hospital = models.ForeignKey(Hospital, on_delete=models.CASCADE, help_text=_('Select the hospital for this employee'))
polyclinic = models.ManyToManyField(Polyclinic, blank=True, help_text=_('Select the polyclinic(s) for this employee'))
phone = models.CharField(_('Phone number'), max_length=15, blank=True, help_text=_('The direct phone number of this employee'))
def __str__(self):
"""str: Returns a readable name for the hospital. Format is [hospital_name] ([city])."""
return '{} ({})'.format(self.user.get_full_name(), self.hospital)

View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

View File

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.