git Reset
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import math
|
import math
|
||||||
|
import time
|
||||||
|
|
||||||
from django.core.validators import MinValueValidator, MaxValueValidator
|
from django.core.validators import MinValueValidator, MaxValueValidator
|
||||||
from django.db import models
|
from django.db import models
|
||||||
@@ -7,6 +8,8 @@ from django.conf import settings
|
|||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
|
#test
|
||||||
|
|
||||||
class Collabs_hour_types(models.Model):
|
class Collabs_hour_types(models.Model):
|
||||||
|
|
||||||
|
|
||||||
@@ -21,6 +24,7 @@ class Collabs_hour_types(models.Model):
|
|||||||
verbose_name = "type"
|
verbose_name = "type"
|
||||||
verbose_name_plural = "types"
|
verbose_name_plural = "types"
|
||||||
|
|
||||||
|
|
||||||
class Collabs_hour(models.Model):
|
class Collabs_hour(models.Model):
|
||||||
|
|
||||||
BASES_CHOICES = [
|
BASES_CHOICES = [
|
||||||
@@ -29,13 +33,14 @@ class Collabs_hour(models.Model):
|
|||||||
]
|
]
|
||||||
|
|
||||||
userName = models.CharField("Auteur", max_length=100)
|
userName = models.CharField("Auteur", max_length=100)
|
||||||
user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name="Collaborateur", on_delete=models.DO_NOTHING, default=0)
|
user = models.ForeignKey(settings.AUTH_USER_MODEL, limit_choices_to={'groups__name': "Intervenants"}, verbose_name="Collaborateur", on_delete=models.DO_NOTHING)
|
||||||
nHour = models.PositiveIntegerField("Heures", default=0, validators=[MinValueValidator(0), MaxValueValidator(23)])
|
nHour = models.PositiveIntegerField("Heures", default=0, validators=[MinValueValidator(0), MaxValueValidator(23)])
|
||||||
nMinutes = models.PositiveIntegerField("Minutes", default=0, validators=[MinValueValidator(0), MaxValueValidator(60)])
|
nMinutes = models.PositiveIntegerField("Minutes", default=0, validators=[MinValueValidator(0), MaxValueValidator(60)])
|
||||||
sRemarques = models.TextField("Remarques", blank=True)
|
sRemarques = models.TextField("Remarques", blank=True)
|
||||||
bNoticed = models.BooleanField("Vérifiée", blank=True, default=False)
|
bNoticed = models.BooleanField("Vérifiée", blank=True, default=False)
|
||||||
dtDate = models.DateField('Date', blank=False)
|
dtDate = models.DateField('Date', blank=False)
|
||||||
sBases = models.CharField('Employé de la base de', max_length=1, choices=BASES_CHOICES,default=1)
|
sBases = models.CharField('Employé de la base de', max_length=1, choices=BASES_CHOICES,default=1)
|
||||||
|
type = models.ForeignKey(Collabs_hour_types, verbose_name="Types", on_delete=models.DO_NOTHING)
|
||||||
dtUpdate = models.DateTimeField('Date de modification', auto_now=True)
|
dtUpdate = models.DateTimeField('Date de modification', auto_now=True)
|
||||||
dtCreated = models.DateTimeField('Date de création', auto_now_add=True)
|
dtCreated = models.DateTimeField('Date de création', auto_now_add=True)
|
||||||
|
|
||||||
@@ -43,7 +48,10 @@ class Collabs_hour(models.Model):
|
|||||||
|
|
||||||
@admin.display( description='Total du mois')
|
@admin.display( description='Total du mois')
|
||||||
def get_total_hour_by_user(self):
|
def get_total_hour_by_user(self):
|
||||||
objs = Collabs_hour.objects.filter(user=self.user,dtCreated__year=self.dtCreated.year, dtCreated__month=self.dtCreated.month)
|
#objs = Collabs_hour.objects.filter(user_id=self.user_id,dtCreated__year=self.dtCreated.year, dtCreated__month=self.dtCreated.month)
|
||||||
|
objs = Collabs_hour.objects.filter(user_id=self.user_id, dtCreated__year=self.dtCreated.year , dtCreated__month=self.dtCreated.month)
|
||||||
|
print(f"user {self.user} dtCreated__year {self.dtCreated.year} dtCreated__month {self.dtCreated.month}")
|
||||||
|
print( Collabs_hour.objects.all())
|
||||||
|
|
||||||
total = 0.0
|
total = 0.0
|
||||||
|
|
||||||
@@ -53,23 +61,26 @@ class Collabs_hour(models.Model):
|
|||||||
|
|
||||||
|
|
||||||
print(total)
|
print(total)
|
||||||
|
print(objs)
|
||||||
|
if total > 0.0:
|
||||||
|
hours = int(total)
|
||||||
|
minutes = (total*60) % 60
|
||||||
|
|
||||||
return str(int(math.floor(total))) + ':' + str(int((total%(math.floor(total)))*60)) + f" ({total})"
|
ret_string = ("%d:%02d" % (hours, minutes))
|
||||||
|
#ret_string = str(int(math.floor(total))) + ':' + str(int((total%(math.floor(total)))*60)) + f" ({total})"
|
||||||
|
#ret_string = time.strftime("%H:%M", time.gmtime(total))
|
||||||
|
else:
|
||||||
|
ret_string = "0"
|
||||||
|
|
||||||
@admin.display(description='Présence de remarques', boolean=True)
|
return ret_string
|
||||||
def has_remarques(self):
|
|
||||||
ret = False
|
def __str__(self):
|
||||||
if self.sRemarques != None and self.sRemarques != '':
|
return f"Heure supplémentaire: {self.user} : {self.dtCreated.strftime('%d.%m.%Y')} "
|
||||||
ret = True
|
|
||||||
return ret
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "heure suplémentaire"
|
verbose_name = "heure supplémentaire"
|
||||||
verbose_name_plural = "heures suplémentaires"
|
verbose_name_plural = "heures supplémentaires"
|
||||||
permissions = (
|
permissions = (
|
||||||
("can_notice", "Peut noter comme traitée"),
|
("can_notice", "Peut noter comme traitée"),
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user