Révision e5afc1aa
Ajouté par Jérôme Schneider il y a environ 10 ans
calebasse/statistics/forms.py | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
from django import forms |
3 | 3 |
from django.forms import Form |
4 |
|
|
5 |
from ajax_select import make_ajax_field |
|
6 |
|
|
7 |
from statistics import Statistic |
|
8 |
|
|
4 |
from ajax_select.fields import AutoCompleteSelectMultipleField |
|
9 | 5 |
|
10 | 6 |
class BaseForm(Form): |
11 | 7 |
display_or_export = forms.BooleanField(label=u'Exporter dans un fichier', required=False, localize=True) |
... | ... | |
19 | 15 |
|
20 | 16 |
class AnnualActivityForm(BaseForm): |
21 | 17 |
start_date = forms.DateField(label=u"Date de l'année souhaitée", required=False, localize=True) |
22 |
participants = make_ajax_field(Statistic, 'participants', 'all-worker-or-group', True)
|
|
18 |
participants = AutoCompleteSelectMultipleField('all-worker-or-group', required=True)
|
|
23 | 19 |
|
24 | 20 |
class PatientsTwoDatesForm(TwoDatesForm): |
25 |
patients = make_ajax_field(Statistic, 'patients', 'patientrecord', True)
|
|
21 |
patients = AutoCompleteSelectMultipleField('patientrecord', required=True)
|
|
26 | 22 |
|
27 | 23 |
class ParticipantsPatientsTwoDatesForm(PatientsTwoDatesForm): |
28 |
participants = make_ajax_field(Statistic, 'participants', 'all-worker-or-group', True)
|
|
24 |
participants = AutoCompleteSelectMultipleField('all-worker-or-group', required=True)
|
|
29 | 25 |
|
30 | 26 |
class PatientsSynthesisForm(TwoDatesForm): |
31 | 27 |
inscriptions = forms.BooleanField(label=u'Seulement les inscriptions', required=False, localize=True) |
28 |
|
calebasse/statistics/statistics.py | ||
---|---|---|
1535 | 1535 |
data[1].append((name, patients.filter(deficiency_in_diagnostic=True).count())) |
1536 | 1536 |
return [[data]] |
1537 | 1537 |
|
1538 |
class Statistic(models.Model): |
|
1539 |
patients = models.ManyToManyField('dossiers.PatientRecord', |
|
1540 |
null=True, blank=True, default=None) |
|
1541 |
participants = models.ManyToManyField('personnes.People', |
|
1542 |
null=True, blank=True, default=None) |
|
1538 |
class Statistic(object): |
|
1543 | 1539 |
in_start_date = None |
1544 | 1540 |
in_end_date = None |
1545 | 1541 |
in_service = None |
... | ... | |
1620 | 1616 |
quoting = _quoting |
1621 | 1617 |
csv.register_dialect('csv_profile', CSVProfile()) |
1622 | 1618 |
encoding = getattr(settings, 'CSV_ENCODING', 'utf-8') |
1623 |
# Python 3: , encoding=encoding |
|
1624 |
# with tempfile.NamedTemporaryFile(delete=False) as temp_out_csv: |
|
1625 |
# try: |
|
1626 |
# writer = csv.writer(temp_out_csv, dialect='csv_profile') |
|
1627 |
# for data_set in self.data: |
|
1628 |
# for data in data_set: |
|
1629 |
# writer.writerow(data[0]) |
|
1630 |
# if len(data) > 1: |
|
1631 |
# for d in data[1]: |
|
1632 |
# writer.writerow(d) |
|
1633 |
# writer.writerow([]) |
|
1634 |
# writer.writerow([]) |
|
1635 |
# return temp_out_csv.name |
|
1636 |
# except Exception, e: |
|
1637 |
# print e |
|
1638 |
# try: |
|
1639 |
# os.unlink(temp_out_pdf.name) |
|
1640 |
# except: |
|
1641 |
# pass |
|
1642 | 1619 |
|
1643 | 1620 |
import codecs |
1644 | 1621 |
filename = None |
... | ... | |
1666 | 1643 |
def get_file(self): |
1667 | 1644 |
self.get_data() |
1668 | 1645 |
return self.render_to_csv() |
1646 |
|
calebasse/statistics/views.py | ||
---|---|---|
100 | 100 |
qs = urllib.urlencode(self.request.POST) |
101 | 101 |
target = '../../detail/%s?%s' % (self.kwargs.get('name'), qs) |
102 | 102 |
return target |
103 |
|
Formats disponibles : Unified diff
calebasse/statistics: don't use Statistic class as a Django model
Fixes #4341