Пример #1
0
def member_detail(request, member_id):
    member = get_object_or_404(Member, pk=member_id)
    #daily_logs = DailyLog.objects.filter(member=member).order_by('visit_date').reverse()
    memberships = Membership.objects.filter(member=member).order_by('start_date').reverse()
    email_logs = SentEmailLog.objects.filter(member=member).order_by('created').reverse()

    if request.method == 'POST':
        if 'send_manual_email' in request.POST:
            key = request.POST.get('message_key')
            email.send_manual(member.user, key)
        elif 'add_note' in request.POST:
            note = request.POST.get('note')
            MemberNote.objects.create(member=member, created_by=request.user, note=note)
        elif 'add_special_day' in request.POST:
            month = request.POST.get('month')
            day = request.POST.get('day')
            year = request.POST.get('year')
            if len(year) == 0:
                year = None
            desc = request.POST.get('description')
            SpecialDay.objects.create(member=member, month=month, day=day, year=year, description=desc)
        else:
            print request.POST

    email_keys = email.valid_message_keys()
    email_keys.remove("all")

    return render_to_response('staff/member_detail.html', {'member': member, 'memberships': memberships, 'email_logs': email_logs, 'email_keys': email_keys, 'settings': settings}, context_instance=RequestContext(request))
Пример #2
0
def detail(request, member_id):
    member = get_object_or_404(Member, pk=member_id)
    #daily_logs = DailyLog.objects.filter(member=member).order_by('visit_date').reverse()
    emergency_contact = member.user.get_emergency_contact()
    memberships = Membership.objects.filter(
        member=member).order_by('start_date').reverse()
    email_logs = SentEmailLog.objects.filter(
        member=member).order_by('created').reverse()

    if request.method == 'POST':
        if 'send_manual_email' in request.POST:
            key = request.POST.get('message_key')
            email.send_manual(member.user, key)
        elif 'add_note' in request.POST:
            note = request.POST.get('note')
            MemberNote.objects.create(member=member,
                                      created_by=request.user,
                                      note=note)
        elif 'add_special_day' in request.POST:
            month = request.POST.get('month')
            day = request.POST.get('day')
            year = request.POST.get('year')
            if len(year) == 0:
                year = None
            desc = request.POST.get('description')
            SpecialDay.objects.create(member=member,
                                      month=month,
                                      day=day,
                                      year=year,
                                      description=desc)
        else:
            print(request.POST)

    email_keys = email.valid_message_keys()
    email_keys.remove("all")

    return render_to_response('staff/member_detail.html', {
        'member': member,
        'emergency_contact': emergency_contact,
        'memberships': memberships,
        'email_logs': email_logs,
        'email_keys': email_keys,
        'settings': settings
    },
                              context_instance=RequestContext(request))
Пример #3
0
    def handle(self, *labels, **options):
        if not labels or len(labels) != 2:
            self.print_keys()
            raise CommandError('Enter a username and message key')

        # Make sure we have a valid user
        user = None
        try:
            user = User.objects.get(username=labels[0])
        except:
            raise CommandError("Invalid username '%s'" % labels[0])

        message = labels[1].lower()
        print("Sending %s..." % message)
        if not email.send_manual(user, message):
            self.print_keys()
            raise CommandError("Invalid message key '%s'" % labels[1])

        print("Email address: %s" % user.email)
Пример #4
0
    def handle(self, *labels, **options):
        if not labels or len(labels) != 2:
            self.print_keys()
            raise CommandError('Enter a username and message key')

        # Make sure we have a valid user
        user = None
        try:
            user = User.objects.get(username=labels[0])
        except:
            raise CommandError("Invalid username '%s'" % labels[0])

        message = labels[1].lower()
        print("Sending %s..." % message)
        if not email.send_manual(user, message):
            self.print_keys()
            raise CommandError("Invalid message key '%s'" % labels[1])

        print("Email address: %s" % user.email)