Esempio n. 1
0
File: export.py Progetto: La0/coach
  def render_to_response(self, context, *args, **kwargs):
    plan = context['plan']

    # Init response
    resp = HttpResponse(content_type='application/pdf')
    resp['Content-Disposition'] = 'attachment; filename="Plan %s - RunReport.pdf"' % plan.name

    # Build pdf directly into response stream
    export = PlanPdfExporter(plan)
    export.render(resp)

    return resp
Esempio n. 2
0
    def render_to_response(self, context, *args, **kwargs):
        plan = context['plan']

        # Init response
        resp = HttpResponse(content_type='application/pdf')
        resp[
            'Content-Disposition'] = 'attachment; filename="Plan %s - RunReport.pdf"' % plan.name

        # Build pdf directly into response stream
        export = PlanPdfExporter(plan)
        export.render(resp)

        return resp
Esempio n. 3
0
File: plans.py Progetto: La0/coach
  def publish(self, users):
    '''
    Publish a plan to specified users
    No verification on the users belonging
     to the creator here
    '''
    if not self.start:
      raise Exception("No start date on plan.")

    # Build the pdf export
    export = PlanPdfExporter(self)
    pdf = export.render()

    for u in users.all():
      # Save plan application
      pa, _ = PlanApplied.objects.get_or_create(user=u, plan=self)

      # Apply the sessions
      nb_applied = 0
      for s in self.sessions.all():
        try:
          s.apply(pa)
          nb_applied += 1
        except Exception, e:
          print 'Failed to apply plan session #%d : %s' % (s.pk, e)

      # Send an email to each user
      if nb_applied > 0:
        self.notify_athlete(u, pdf)
Esempio n. 4
0
    def publish(self, users):
        '''
    Publish a plan to specified users
    No verification on the users belonging
     to the creator here
    '''
        if not self.start:
            raise Exception("No start date on plan.")

        # Build the pdf export
        export = PlanPdfExporter(self)
        pdf = export.render()

        for u in users.all():
            # Save plan application
            pa, _ = PlanApplied.objects.get_or_create(user=u, plan=self)

            # Apply the sessions
            nb_applied = 0
            for s in self.sessions.all():
                try:
                    s.apply(pa)
                    nb_applied += 1
                except Exception, e:
                    print 'Failed to apply plan session #%d : %s' % (s.pk, e)

            # Send an email to each user
            if nb_applied > 0:
                self.notify_athlete(u, pdf)