Browse Source

Merge branch 'producao'

Conflicts:
	sigi/apps/metas/views.py
producao
Marcio Mazza 10 years ago
parent
commit
4b88453172
  1. 22
      moodlerouter.py
  2. 0
      sigi/apps/mdl/__init__.py
  3. 3
      sigi/apps/mdl/admin.py
  4. 5091
      sigi/apps/mdl/base_models.py
  5. 327
      sigi/apps/mdl/models.py
  6. 3
      sigi/apps/mdl/tests.py
  7. 3
      sigi/apps/mdl/views.py
  8. 6
      sigi/apps/metas/views.py
  9. 0
      sigi/apps/saberes/__init__.py
  10. 12
      sigi/apps/saberes/admin.py
  11. 51
      sigi/apps/saberes/models.py
  12. 20
      sigi/apps/saberes/templates/saberes/dashboard.html
  13. 22
      sigi/apps/saberes/templates/saberes/snippets.html
  14. 3
      sigi/apps/saberes/tests.py
  15. 6
      sigi/apps/saberes/urls.py
  16. 54
      sigi/apps/saberes/views.py
  17. 6
      sigi/context_processors.py
  18. 13
      sigi/settings/base.py
  19. 4
      sigi/settings/dev.py
  20. 4
      sigi/urls.py
  21. 4
      sigiStatic/css/base_site.css
  22. 11
      sigiStatic/js/metas/mapa.js
  23. 11
      templates/snippets/modules/charts-convenios.html

22
moodlerouter.py

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
class MoodleRouter(object):
def db_for_read(self, model, **hints):
if model._meta.app_label == 'mdl':
return 'moodle'
return None
def db_for_write(self, model, **hints):
if model._meta.app_label == 'mdl':
return 'moodle'
return None
def allow_relation(self, obj1, obj2, **hints):
if obj1._meta.app_label == 'mdl' and obj2._meta.app_label == 'mdl':
return True
return None
def allow_migrate(self, db, model):
if model._meta.app_label == 'mdl':
return False
return None

0
sigi/apps/mdl/__init__.py

3
sigi/apps/mdl/admin.py

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

5091
sigi/apps/mdl/base_models.py

File diff suppressed because it is too large

327
sigi/apps/mdl/models.py

@ -0,0 +1,327 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
class CourseStatus(models.Model):
# databaseview: (postgresql dialect):
#
# CREATE OR REPLACE VIEW ilb_course_status AS
# SELECT DISTINCT u.id AS userid, c.id AS courseid, c.category,
# CASE
# WHEN e.enrol::text = 'ilbeadtutorado'::text AND ue.status = 1::bigint THEN 'Matrícula rejeitada'::text
# WHEN e.enrol::text = 'ilbead'::text AND ue.timeend < date_part('epoch'::text, now())::integer THEN 'Em curso'::text
# WHEN co.timestarted = 0 OR co.timestarted IS NULL THEN 'Abandono'::text
# WHEN co.timestarted > 0 AND co.timecompleted IS NULL THEN 'Reprovado'::text
# WHEN co.timecompleted IS NOT NULL THEN 'Aprovado'::text
# WHEN e.enrol::text <> 'ilbeadtutorado'::text THEN '?'::text
# ELSE ''::text
# END AS status
# FROM mdl_user u
# JOIN mdl_user_enrolments ue ON ue.userid = u.id
# JOIN mdl_enrol e ON e.id = ue.enrolid
# JOIN mdl_course c ON c.id = e.courseid
# LEFT JOIN mdl_course_completions co ON co.userid = u.id AND co.course = c.id;
userid = models.IntegerField(primary_key=True)
courseid = models.IntegerField()
category = models.IntegerField()
status = models.CharField(max_length=100)
class Meta:
managed = False
db_table = 'ilb_course_status'
class Cohort(models.Model):
id = models.BigIntegerField(primary_key=True)
context = models.ForeignKey('Context', db_column='contextid')
name = models.CharField(max_length=254)
idnumber = models.CharField(max_length=100, blank=True)
description = models.TextField(blank=True)
descriptionformat = models.SmallIntegerField()
component = models.CharField(max_length=100)
timecreated = models.BigIntegerField()
timemodified = models.BigIntegerField()
# Manytomany
members = models.ManyToManyField('User', through='CohortMembers')
class Meta:
managed = False
db_table = 'mdl_cohort'
def __unicode__(self):
return self.name
class CohortMembers(models.Model):
id = models.BigIntegerField(primary_key=True)
cohort = models.ForeignKey('Cohort', db_column='cohortid')
user = models.ForeignKey('User', db_column='userid')
timeadded = models.BigIntegerField()
class Meta:
managed = False
db_table = 'mdl_cohort_members'
class Context(models.Model):
CONTEXT_SYSTEM = 10 # System context level - only one instance in every system
CONTEXT_USER = 30 # User context level - one instance for each user describing what others can do to user
CONTEXT_COURSECAT = 40 # Course category context level - one instance for each category
CONTEXT_COURSE = 50 # Course context level - one instances for each course
CONTEXT_MODULE = 70 # Course module context level - one instance for each course module
CONTEXT_BLOCK = 80 # Block context level - one instance for each block, sticky blocks are tricky
# because ppl think they should be able to override them at lower contexts.
# Any other context level instance can be parent of block context.
id = models.BigIntegerField(primary_key=True)
contextlevel = models.BigIntegerField()
instanceid = models.BigIntegerField()
path = models.CharField(max_length=255, blank=True)
depth = models.SmallIntegerField()
class Meta:
managed = False
db_table = 'mdl_context'
def __unicode__(self):
return self.path
class Course(models.Model):
id = models.BigIntegerField(primary_key=True)
category = models.ForeignKey('CourseCategories', db_column='category', related_name='courses')
sortorder = models.BigIntegerField()
fullname = models.CharField(max_length=254)
shortname = models.CharField(max_length=255)
idnumber = models.CharField(max_length=100)
summary = models.TextField(blank=True)
format = models.CharField(max_length=21)
showgrades = models.SmallIntegerField()
modinfo = models.TextField(blank=True)
newsitems = models.IntegerField()
startdate = models.BigIntegerField()
marker = models.BigIntegerField()
maxbytes = models.BigIntegerField()
showreports = models.SmallIntegerField()
visible = models.SmallIntegerField()
groupmode = models.SmallIntegerField()
groupmodeforce = models.SmallIntegerField()
lang = models.CharField(max_length=30)
theme = models.CharField(max_length=50)
timecreated = models.BigIntegerField()
timemodified = models.BigIntegerField()
requested = models.SmallIntegerField()
defaultgroupingid = models.BigIntegerField()
enrolmax = models.BigIntegerField()
enablecompletion = models.SmallIntegerField()
legacyfiles = models.SmallIntegerField()
summaryformat = models.SmallIntegerField()
completionnotify = models.SmallIntegerField()
visibleold = models.SmallIntegerField()
sectioncache = models.TextField(blank=True)
class Meta:
managed = False
db_table = 'mdl_course'
ordering = ['sortorder',]
def __unicode__(self):
return self.fullname
def total_alunos(self):
return sum(e.user_enrolments.count() for e in self.enrols.all())
def total_ativos(self):
return sum(e.user_enrolments.filter(status=0).count() for e in self.enrols.all())
def get_matriculas(self):
q = UserEnrolments.objects.none()
for e in self.enrols.all():
q = q | e.user_enrolments.all()
return q
class CourseCategories(models.Model):
id = models.BigIntegerField(primary_key=True)
name = models.CharField(max_length=255)
description = models.TextField(blank=True)
parent = models.ForeignKey('CourseCategories', db_column='parent', related_name='children')
sortorder = models.BigIntegerField()
coursecount = models.BigIntegerField()
visible = models.SmallIntegerField()
timemodified = models.BigIntegerField()
depth = models.BigIntegerField()
path = models.CharField(max_length=255)
theme = models.CharField(max_length=50, blank=True)
descriptionformat = models.SmallIntegerField()
visibleold = models.SmallIntegerField()
idnumber = models.CharField(max_length=100, blank=True)
class Meta:
managed = False
db_table = 'mdl_course_categories'
ordering = ['sortorder',]
def __unicode__(self):
return self.name
def context(self):
return Context.objects.get(instanceid=self.id, contextlevel=Context.CONTEXT_COURSECAT)
def total_turmas(self):
return self.coursecount + sum([c.coursecount for c in self.children.all()])
def total_alunos(self):
total = 0
total = total + sum(c.total_alunos() for c in self.courses.all())
total = total + sum(c.total_alunos() for c in self.children.all())
return total
def cohortids(self):
cids = [c.pk for c in self.context().cohort_set.all()]
for c in self.children.all():
cids = cids + c.cohortids()
return cids
def total_alunos_cohort(self):
return sum([c.members.distinct().count() for c in Cohort.objects.filter(pk__in=self.cohortids())])
def get_all_courses(self, only_visible=False):
if only_visible:
q = self.courses.filter(visible=1)
else:
q = self.courses.all()
for c in self.children.all():
q = q | c.get_all_courses(only_visible=only_visible)
return q
class CourseCompletions(models.Model):
id = models.BigIntegerField(primary_key=True)
user = models.ForeignKey('User', db_column='userid')
course = models.ForeignKey('Course', db_column='course')
timeenrolled = models.BigIntegerField()
timestarted = models.BigIntegerField()
timecompleted = models.BigIntegerField(blank=True, null=True)
reaggregate = models.BigIntegerField()
class Meta:
managed = False
db_table = 'mdl_course_completions'
class Enrol(models.Model):
id = models.BigIntegerField(primary_key=True)
enrol = models.CharField(max_length=20)
status = models.BigIntegerField()
course = models.ForeignKey('Course', db_column='courseid', related_name='enrols')
sortorder = models.BigIntegerField()
name = models.CharField(max_length=255, blank=True)
enrolperiod = models.BigIntegerField(blank=True, null=True)
enrolstartdate = models.BigIntegerField(blank=True, null=True)
enrolenddate = models.BigIntegerField(blank=True, null=True)
expirynotify = models.SmallIntegerField(blank=True, null=True)
expirythreshold = models.BigIntegerField(blank=True, null=True)
notifyall = models.SmallIntegerField(blank=True, null=True)
password = models.CharField(max_length=50, blank=True)
cost = models.CharField(max_length=20, blank=True)
currency = models.CharField(max_length=3, blank=True)
roleid = models.BigIntegerField(blank=True, null=True)
customint1 = models.BigIntegerField(blank=True, null=True)
customint2 = models.BigIntegerField(blank=True, null=True)
customint3 = models.BigIntegerField(blank=True, null=True)
customint4 = models.BigIntegerField(blank=True, null=True)
customchar1 = models.CharField(max_length=255, blank=True)
customchar2 = models.CharField(max_length=255, blank=True)
customdec1 = models.DecimalField(max_digits=12, decimal_places=7, blank=True, null=True)
customdec2 = models.DecimalField(max_digits=12, decimal_places=7, blank=True, null=True)
customtext1 = models.TextField(blank=True)
customtext2 = models.TextField(blank=True)
timecreated = models.BigIntegerField()
timemodified = models.BigIntegerField()
customint5 = models.BigIntegerField(blank=True, null=True)
customint6 = models.BigIntegerField(blank=True, null=True)
customint7 = models.BigIntegerField(blank=True, null=True)
customint8 = models.BigIntegerField(blank=True, null=True)
customchar3 = models.CharField(max_length=1333, blank=True)
customtext3 = models.TextField(blank=True)
customtext4 = models.TextField(blank=True)
class Meta:
managed = False
db_table = 'mdl_enrol'
ordering = ['sortorder',]
def __unicode__(self):
if not self.name:
return self.enrol
return self.name
class User(models.Model):
id = models.BigIntegerField(primary_key=True)
auth = models.CharField(max_length=20)
confirmed = models.SmallIntegerField()
policyagreed = models.SmallIntegerField()
deleted = models.SmallIntegerField()
mnethostid = models.BigIntegerField()
username = models.CharField(max_length=100)
password = models.CharField(max_length=255)
firstname = models.CharField(max_length=100)
lastname = models.CharField(max_length=100)
email = models.CharField(max_length=100)
emailstop = models.SmallIntegerField()
icq = models.CharField(max_length=15)
skype = models.CharField(max_length=50)
yahoo = models.CharField(max_length=50)
aim = models.CharField(max_length=50)
msn = models.CharField(max_length=50)
phone1 = models.CharField(max_length=20)
phone2 = models.CharField(max_length=20)
institution = models.CharField(max_length=40)
department = models.CharField(max_length=30)
address = models.CharField(max_length=70)
city = models.CharField(max_length=120)
country = models.CharField(max_length=2)
lang = models.CharField(max_length=30)
theme = models.CharField(max_length=50)
timezone = models.CharField(max_length=100)
firstaccess = models.BigIntegerField()
lastaccess = models.BigIntegerField()
lastlogin = models.BigIntegerField()
currentlogin = models.BigIntegerField()
lastip = models.CharField(max_length=45)
secret = models.CharField(max_length=15)
picture = models.BigIntegerField()
url = models.CharField(max_length=255)
description = models.TextField(blank=True)
mailformat = models.SmallIntegerField()
maildigest = models.SmallIntegerField()
maildisplay = models.SmallIntegerField()
htmleditor = models.SmallIntegerField()
autosubscribe = models.SmallIntegerField()
trackforums = models.SmallIntegerField()
timemodified = models.BigIntegerField()
trustbitmask = models.BigIntegerField()
imagealt = models.CharField(max_length=255, blank=True)
idnumber = models.CharField(max_length=255)
descriptionformat = models.SmallIntegerField()
timecreated = models.BigIntegerField()
suspended = models.SmallIntegerField()
class Meta:
managed = False
db_table = 'mdl_user'
def __unicode__(self):
return u'%s %s' % (self.firstname, self.lastname)
class UserEnrolments(models.Model):
id = models.BigIntegerField(primary_key=True)
status = models.BigIntegerField()
enrol = models.ForeignKey('Enrol', db_column='enrolid', related_name='user_enrolments')
user = models.ForeignKey('User', db_column='userid', related_name='Enrolments')
timestart = models.BigIntegerField()
timeend = models.BigIntegerField()
modifierid = models.BigIntegerField()
timecreated = models.BigIntegerField()
timemodified = models.BigIntegerField()
class Meta:
managed = False
db_table = 'mdl_user_enrolments'

3
sigi/apps/mdl/tests.py

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

3
sigi/apps/mdl/views.py

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

6
sigi/apps/metas/views.py

@ -2,6 +2,7 @@
import csv import csv
import json as simplejson # XXX trocar isso por simplesmente import json e refatorar o codigo import json as simplejson # XXX trocar isso por simplesmente import json e refatorar o codigo
import os import os
import time
from functools import reduce from functools import reduce
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
@ -12,8 +13,8 @@ from django.http import HttpResponse
from django.shortcuts import render_to_response from django.shortcuts import render_to_response
from django.template import RequestContext from django.template import RequestContext
from django.utils.datastructures import SortedDict from django.utils.datastructures import SortedDict
from django.utils.translation import ugettext as _
from django.views.decorators.cache import cache_page from django.views.decorators.cache import cache_page
from easy_thumbnails.templatetags.thumbnail import thumbnail_url
from sigi.apps.casas.models import CasaLegislativa from sigi.apps.casas.models import CasaLegislativa
from sigi.apps.contatos.models import UnidadeFederativa from sigi.apps.contatos.models import UnidadeFederativa
@ -284,7 +285,6 @@ def gera_map_data_file(cronjob=False):
Caso cronjob seja True, retorna log de tempo gasto na geração ou a mensagem do erro Caso cronjob seja True, retorna log de tempo gasto na geração ou a mensagem do erro
que impediu a gravação do arquivo. que impediu a gravação do arquivo.
''' '''
import time
start = time.time() start = time.time()
casas = {} casas = {}
@ -298,6 +298,8 @@ def gera_map_data_file(cronjob=False):
casa = { casa = {
'nome': c.nome + ', ' + c.municipio.uf.sigla, 'nome': c.nome + ', ' + c.municipio.uf.sigla,
'icone': '/static/img/mapmarker.png', 'icone': '/static/img/mapmarker.png',
'thumb': thumbnail_url(c.foto, 'small'),
'foto': (c.foto.url if c.foto else ''),
'lat': str(c.municipio.latitude), 'lat': str(c.municipio.latitude),
'lng': str(c.municipio.longitude), 'lng': str(c.municipio.longitude),
'estado': c.municipio.uf.sigla, 'estado': c.municipio.uf.sigla,

0
sigi/apps/saberes/__init__.py

12
sigi/apps/saberes/admin.py

@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
from django.utils.translation import ugettext as _
from django.contrib import admin
from sigi.apps.saberes.models import CategoriasInteresse
class CategoriasInteresseAdmin(admin.ModelAdmin):
list_display = ('prefixo', 'descricao', 'count_categorias',)
def count_categorias(self, obj):
return obj.categorias().count()
count_categorias.short_description = _("Categorias que casam")
admin.site.register(CategoriasInteresse, CategoriasInteresseAdmin)

51
sigi/apps/saberes/models.py

@ -0,0 +1,51 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.utils.translation import ugettext as _
from django.db import models
from django.db.models import Q
from sigi.apps.mdl.models import Course, CourseCategories, CourseCompletions, UserEnrolments
class CategoriasInteresse(models.Model):
prefixo = models.CharField(_(u"Prefixo das categorias no Moodle"), max_length=100,
help_text=_(u"Identifica as categorias no Moodle (campo idnumber) relacionadas a este interesse"))
descricao = models.CharField(_(u"Descrição"), max_length=100)
sigla = models.CharField(_(u"Sigla"), max_length=20)
coorte = models.BooleanField(_(u"Usa Cohorte"), default=False, help_text=_(u"Usa cohorte para calcular o número de matrículas/alunos"))
apurar_alunos = models.BooleanField(_(u"Apurar alunos"), default=False, help_text=_(u"Indica que deve-se verificar o perfil da"\
+ " inscrição para saber se é um aluno ou se a matrícula foi rejeitada"))
apurar_conclusao = models.BooleanField(_(u"Apurar conclusão"), default=False, help_text=_(u"Indica se o dashboard mostrará o "\
+ "número de alunos aprovados, reprovados e desistentes"))
class Meta:
verbose_name = _(u'Categorias de interesse')
def __unicode__(self):
return self.descricao
def categorias(self):
return CourseCategories.objects.filter(idnumber__startswith=self.prefixo)
def get_all_courses(self, only_visible=False):
q = Course.objects.none()
for categoria in self.categorias():
q = q | categoria.get_all_courses(only_visible=only_visible)
return q
def get_all_completions(self):
q = CourseCompletions.objects.none()
for c in self.get_all_courses():
q = q | c.coursecompletions_set.all()
return q
def get_all_enrolments(self):
q = UserEnrolments.objects.none()
for c in self.get_all_courses():
q = q | c.get_matriculas()
return q
def total_alunos(self):
if self.coorte:
return sum(c.total_alunos_cohort() for c in self.categorias())
else:
return sum([c.total_alunos() for c in self.categorias()])

20
sigi/apps/saberes/templates/saberes/dashboard.html

@ -0,0 +1,20 @@
{% extends "admin/base_site.html" %}
{% block extrastyle %}
{{ block.super }}
<style>
td.number {
text-align: right;
}
.panel-body {
max-height: 400px;
overflow: auto;
}
</style>
{% endblock %}
{% block content %}
<div id="content-main">
{% include "saberes/snippets.html" %}
</div>
{% endblock %}

22
sigi/apps/saberes/templates/saberes/snippets.html

@ -0,0 +1,22 @@
{% load charts %}
<div class="row row-flex row-flex-wrap">
{% for painel in paineis %}
<div class="col-md-4">
<div class="panel panel-primary flex-col">
<div class="panel-heading">{{ painel.titulo }}</div>
<div class="panel-body">
<table class='table'>
{% for linha in painel.dados %}
<tr>
<th>{{ linha.descricao }}</th>
<td class='number'>{{ linha.valor }}</td>
</tr>
{% endfor %}
</table>
</div>
</div>
</div>
{% cycle '' '' '</div><div class="row">' %}
{% endfor %}
</div>

3
sigi/apps/saberes/tests.py

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

6
sigi/apps/saberes/urls.py

@ -0,0 +1,6 @@
# coding: utf-8
from django.conf.urls import patterns, url
urlpatterns = patterns('sigi.apps.saberes.views',
url(r'^dashboard/$', 'dashboard', name="saberes-dashboard-view"),
)

54
sigi/apps/saberes/views.py

@ -0,0 +1,54 @@
# -*- coding: utf-8 -*-
from django.utils.translation import ugettext as _
from django.db.models import Count
from django.shortcuts import render, render_to_response
from django.template import RequestContext
from sigi.apps.mdl.models import User, CourseStatus
from sigi.apps.saberes.models import CategoriasInteresse
def dashboard(request):
areas = []
numeros = [
{'descricao': _(u'Total de usuários cadastrados'), 'valor': User.objects.count()},
{'descricao': _(u'Novos usuários cadastrados') , 'valor': User.objects.filter(firstaccess__gte=1392326052).count()}
]
for ci in CategoriasInteresse.objects.all():
matriculas = ci.total_alunos()
numeros.append({'descricao': _(u'Total de matrículas em %s' % ci.descricao.lower()), 'valor': matriculas})
area = {'titulo': ci.descricao, 'dados': [{'descricao': _(u'Total de matrículas'), 'valor': matriculas}]}
for course in ci.get_all_courses(only_visible=True):
area['dados'].append({'descricao': course.fullname, 'valor': course.total_alunos()})
# if ci.apurar_alunos: # Apurar número de alunos
# valor = sum([curso.total_ativos() for curso in ci.get_all_courses()])
# area['dados'].append({'descricao': _(u'Total de alunos aceitos'), 'valor': valor})
# if ci.apurar_conclusao:
# cl = [curso.id for curso in ci.get_all_courses()]
# for cs in CourseStatus.objects.filter(courseid__in=cl).values('status').annotate(valor=Count('userid')):
# area['dados'].append({'descricao': cs['status'], 'valor': cs['valor']})
#
areas.append(area)
paineis = [{'titulo': _(u'Saberes em números'), 'dados': numeros}] + areas
totais = []
# for i in MapaCategorias.INTERESSE_CHOICES:
# totais.append({'nome': i[1], 'total_turmas': '', 'total_alunos': '', 'padding': 0})
# for mapa in MapaCategorias.objects.filter(area_interesse=i[0]):
# totais.append({'nome': mapa.categoria.name, 'total_turmas': mapa.total_turmas(), 'total_alunos': mapa.total_alunos(), 'padding': 1})
# for c in mapa.categoria.children.all():
# totais.append({'nome': c.name, 'total_turmas': c.total_turmas(), 'total_alunos': c.total_alunos(), 'padding': 2})
tutorias = []
# for mapa in MapaCategorias.objects.filter(area_interesse='CT'):
# tutorias.append({'nome': mapa.categoria.name, 'inscritos': mapa.total_alunos(), 'padding': 0})
# for c in mapa.categoria.courses.all():
# tutorias.append({'nome': c.fullname, 'inscritos': c.total_alunos(), 'padding': 1})
extra_context = {'numeros': numeros, 'paineis': paineis, 'totais': totais, 'tutorias': tutorias}
return render_to_response('saberes/dashboard.html', extra_context, context_instance=RequestContext(request))

6
sigi/context_processors.py

@ -167,11 +167,17 @@ def busca_informacoes_seit():
'novos_mes_atual': 'Novas casas em %s/%s' % (mes_atual.month, mes_atual.year)}] 'novos_mes_atual': 'Novas casas em %s/%s' % (mes_atual.month, mes_atual.year)}]
for tipo_servico in TipoServico.objects.all(): for tipo_servico in TipoServico.objects.all():
por_mes = []
for mes in range(1,13):
por_mes.append({'mes': '%02d/%s' % (mes,datetime.date.today().year),
'total': tipo_servico.servico_set.filter(data_desativacao=None, data_ativacao__year=mes_atual.year, data_ativacao__month=mes).count()})
result.append( result.append(
{'nome': tipo_servico.nome, {'nome': tipo_servico.nome,
'total': tipo_servico.servico_set.filter(data_desativacao=None).count(), 'total': tipo_servico.servico_set.filter(data_desativacao=None).count(),
'novos_mes_anterior': tipo_servico.servico_set.filter(data_desativacao=None, data_ativacao__year=mes_anterior.year, data_ativacao__month=mes_anterior.month).count(), 'novos_mes_anterior': tipo_servico.servico_set.filter(data_desativacao=None, data_ativacao__year=mes_anterior.year, data_ativacao__month=mes_anterior.month).count(),
'novos_mes_atual': tipo_servico.servico_set.filter(data_desativacao=None, data_ativacao__year=mes_atual.year, data_ativacao__month=mes_atual.month).count(), 'novos_mes_atual': tipo_servico.servico_set.filter(data_desativacao=None, data_ativacao__year=mes_atual.year, data_ativacao__month=mes_atual.month).count(),
'novos_por_mes': por_mes,
} }
) )

13
sigi/settings/base.py

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
""" """
Django settings for sigi project. Django settings for sigi project.
@ -37,6 +38,9 @@ TEMPLATE_LOADERS = ('django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader', 'django.template.loaders.app_directories.Loader',
) )
# Database routers
DATABASE_ROUTERS = ['moodlerouter.MoodleRouter',]
# Application definition # Application definition
INSTALLED_APPS = ( INSTALLED_APPS = (
@ -64,6 +68,10 @@ INSTALLED_APPS = (
'sigi.apps.financeiro', 'sigi.apps.financeiro',
'sigi.apps.diagnosticos', 'sigi.apps.diagnosticos',
# Integração com Saberes (moodle)
'sigi.apps.mdl',
'sigi.apps.saberes',
# Third-party apps # Third-party apps
'localflavor', 'localflavor',
'reporting', 'reporting',
@ -132,5 +140,10 @@ THUMBNAIL_PROCESSORS = (
'image_cropping.thumbnail_processors.crop_corners', 'image_cropping.thumbnail_processors.crop_corners',
) + thumbnail_settings.THUMBNAIL_PROCESSORS ) + thumbnail_settings.THUMBNAIL_PROCESSORS
THUMBNAIL_ALIASES = {
'': {
'small': {'size': (300, 225), 'crop': True,},
},
}
IMAGE_CROPPING_SIZE_WARNING = True IMAGE_CROPPING_SIZE_WARNING = True
IMAGE_CROPPING_THUMB_SIZE = (800, 600) IMAGE_CROPPING_THUMB_SIZE = (800, 600)

4
sigi/settings/dev.py

@ -8,6 +8,10 @@ DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.sqlite3', 'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'sigi.db'), 'NAME': os.path.join(BASE_DIR, 'sigi.db'),
},
'moodle': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'moodle.db'),
} }
} }

4
sigi/urls.py

@ -16,12 +16,14 @@ urlpatterns = patterns('',
url(r'^diagnosticos/', include('sigi.apps.diagnosticos.urls')), url(r'^diagnosticos/', include('sigi.apps.diagnosticos.urls')),
url(r'^servidores/', include('sigi.apps.servidores.urls')), url(r'^servidores/', include('sigi.apps.servidores.urls')),
url(r'^servicos/', include('sigi.apps.servicos.urls')), url(r'^servicos/', include('sigi.apps.servicos.urls')),
url(r'^saberes/', include('sigi.apps.saberes.urls')),
url(r'^dashboard/', include('sigi.apps.metas.urls')), url(r'^dashboard/', include('sigi.apps.metas.urls')),
url(r'^', include(admin.site.urls)), url(r'^', include(admin.site.urls)),
# to enable language selection # to enable language selection
url(r'^i18n/', include('django.conf.urls.i18n')), # Suspended
#url(r'^i18n/', include('django.conf.urls.i18n')),
) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) ) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

4
sigiStatic/css/base_site.css

@ -234,3 +234,7 @@ h1 {
.dropdown-menu .clear-all-filter a { .dropdown-menu .clear-all-filter a {
color: #357ebd; color: #357ebd;
} }
/*Fixing Google Maps API conflict with bootstrap. */
.container-flex > div[class*='col-'] #map div, .row-flex > div[class*='col-'] #map div {
width: initial;
}

11
sigiStatic/js/metas/mapa.js

@ -43,7 +43,16 @@
icon: '/static/img/mapmarker.png' icon: '/static/img/mapmarker.png'
} }
var mark = new google.maps.Marker(markData); var mark = new google.maps.Marker(markData);
var infoWin = new google.maps.InfoWindow({content: '<strong>' + municipio.nome + '</strong><br/><br/>' + municipio.info }); var iwcontent = '<strong>' + municipio.nome + '</strong><br/><br/>' +
municipio.info;
if (municipio.thumb != '') {
iwcontent = iwcontent + '<br/><br/>' +
'<a href="' + municipio.foto + '" target="_blank">' +
'<img src="' + municipio.thumb + '"></a>';
}
var infoWin = new google.maps.InfoWindow({content: iwcontent });
linkMarkMessage(mark, infoWin, map); linkMarkMessage(mark, infoWin, map);
municipio['mapmark'] = mark; municipio['mapmark'] = mark;
municipio['infowindow'] = infoWin; municipio['infowindow'] = infoWin;

11
templates/snippets/modules/charts-convenios.html

@ -65,7 +65,16 @@
<th>{{ servico.novos_mes_anterior }}</th> <th>{{ servico.novos_mes_anterior }}</th>
<th>{{ servico.novos_mes_atual }}</th> <th>{{ servico.novos_mes_atual }}</th>
{% else %} {% else %}
<th>{{ servico.nome }}</th> <th class="dropdown">
<a id="ddm-{{ servico.nome }}" data-toggle="dropdown" href="#">
{{ servico.nome }}
</a>
<table class="table table-condensed numeros servicos dropdown-menu" role="menu" aria-labelledby="ddm-{{ servico.nome }}">
{% for mes in servico.novos_por_mes %}
<tr><th>{{ mes.mes }}</th><td>{{ mes.total }}</td></tr>
{% endfor %}
</table>
</th>
<td>{{ servico.total }}</td> <td>{{ servico.total }}</td>
<td>{{ servico.novos_mes_anterior }}</td> <td>{{ servico.novos_mes_anterior }}</td>
<td>{{ servico.novos_mes_atual }}</td> <td>{{ servico.novos_mes_atual }}</td>

Loading…
Cancel
Save