Skip to content
Permalink
Browse files

fixed forms, fixed line graph analytics, fixed template null vals

  • Loading branch information...
Krocodial
Krocodial committed Oct 9, 2019
1 parent eda5f8a commit f455940e84e547920c10533990e855184de81ef5
@@ -12,7 +12,6 @@ def ready(self):
if not model.objects.filter(queue='counter').count() > 0:
calc_scheduler(repeat=120)
except:
print('here')
pass
'''
from background_task.models import Task
@@ -133,7 +133,7 @@ class Meta:
model = Classification
fields = ['classification', 'protected_type', 'owner', 'dependents', 'notes', 'masking', 'state']

def save(self, user, approver):
def save(self, user, approver=None):
classy = super(LogDetailSubmitForm, self).save(commit=False)
classy.save(user, approver)
return classy
@@ -169,7 +169,7 @@ def clean(self):
)


def save(self, user, approver):
def save(self, user, approver=None):
classy = super(LogDetailForm, self).save(commit=False)
classy.save(user, approver)
return classy
@@ -235,7 +235,7 @@ <h5 class="modal-title custom-colour" id="batchH">Change Classification</h5>
<td>{{tuple.column}}</td>
<td>{{translate|get_item:tuple.classification}}</td>
<td>{{translate|get_item:tuple.protected_type}}</td>
<td>{{tuple.owner}}</td>
<td>{% if tuple.owner %}{{tuple.owner}}{% endif %}</td>
</tr>
<tr class="hiddenRows{{forloop.counter}}">
<td colspan="8">
@@ -128,7 +128,7 @@ <h3 class=""><strong>Detailed view</strong></h3>
<td>{{item.approver.first_name}}</td>
<td>{{translate|get_item:item.classification}}</td>
<td>{{translate|get_item:item.protected_type}}</td>
<td>{{item.owner}}</td>
<td>{% if item.owner %}{{item.owner}}{% endif %}</td>
<td>[
{% for dep in item.dependents.all %}
{{dep.name}}
@@ -46,7 +46,7 @@

<td><a href={% url 'classy:log_detail' tuple.classy_id %}>{{tuple.classy_id}}</a></td>
<td>{{flag_translate|get_item:tuple.flag}}</td>
<td>{{tuple.owner}}</td>
<td>{% if tuple.owner %}{{tuple.owner}}{% endif %}</td>
<td>{{translate|get_item:tuple.classification}}</td>
<td>{{translate|get_item:tuple.protected_type}}</td>
<td>{{tuple.user.first_name}}</td>
@@ -340,7 +340,7 @@ def log_detail(request, classy_id):

form = LogDetailSubmitForm(data, instance=obj)
if form.is_valid() and form.has_changed():
form.save(request.user.pk, request.user.pk)
form.save(request.user.pk)
form.save_m2m()

form = LogDetailForm(initial=model_to_dict(obj))
@@ -776,8 +776,6 @@ def home(request):

nodeData['labels'] = ex_options + ex_poptions



if queryset.count() == 0:
empty = True
else:
@@ -814,57 +812,59 @@ def home(request):
'UN': 'rgb(219,213,181,0.3)'
}

today = timezone.now().date()
d = today - timezone.timedelta(days=29)
new = ClassificationCount.objects.filter(date__gte=d, user=request.user)
prev = ClassificationCount.objects.filter(date__lt=d, user=request.user).values('date').order_by('-date')


initial = {}

for op in options:
if op in ['CO', 'PE']:
for pop in poptions:
keys[op+':'+pop] = []
if prev.count() > 0:
tmp = ClassificationCount.objects.get(date=str(prev[0]['date']), classification=op, protected_type=pop, user=request.user)
initial[op+':'+pop] = tmp.count
else:
initial[op+':'+pop] = 0
else:
keys[op] = []
if prev.count() > 0:
tmp = ClassificationCount.objects.get(date=str(prev[0]['date']), classification=op, protected_type='', user=request.user)
initial[op] = tmp.count
else:
initial[op] = 0



d = timezone.now().date() - timezone.timedelta(days=29)
tmp = ClassificationCount.objects.filter(date__gte=d, user=request.user)
if tmp.count() > 0:
if new.count() > 0:
for i in range(30):
t = 29 - i
d = timezone.now().date() - timezone.timedelta(days=t)
d = today - timezone.timedelta(days=t)
for clas, arr in keys.items():
clas = clas + ':'
dic = clas.split(':')
try:
tmp = ClassificationCount.objects.get(date=d, classification=dic[0], protected_type=dic[1], user=request.user)
if len(dic) > 1:
tmp = ClassificationCount.objects.get(date=d, classification=dic[0], protected_type=dic[1], user=request.user)
else:
tmp = ClassificationCount.objects.get(date=d, classification=dic[0], protected_type='', user=request.user)
arr.append(tmp.count)
initial[clas] = tmp.count
except ClassificationCount.DoesNotExist:
if len(arr) > 0:
arr.append(arr[-1])
else:
arr.append(0)
arr.append(initial[clas])
except ClassificationCount.MultipleObjectsReturned:
arr.append(0)
arr.append(initial[clas])

else:
arr = {}
date = ClassificationCount.objects.all().values('date').order_by('-date')
if date.count() < 1:
for key, array in keys.items():
array = [0 for i in range(30)]
else:
date = str(date[0]['date'])
for clas in keys:
clas = clas + ':'
dic = clas.split(':')
try:
tmp = ClassificationCount.objects.get(date=date, classification=dic[0], protected_type=dic[1], user=request.user)

arr[clas.strip(':')] = tmp.count
except:
arr[clas.strip(':')] = 0
for key, array in keys.items():
for i in range(30):
for key, array in keys.items():
array.append(arr[key])
array.append(initial[key])

for i in range(30):
t = 29 - i
d = timezone.now().date() - timezone.timedelta(days=t)
d = today - timezone.timedelta(days=t)
dates.append(str(d))
for clas, arr in keys.items():
obj = {}

0 comments on commit f455940

Please sign in to comment.
You can’t perform that action at this time.