Exemple #1
0
def dashboard(request, rescuetime_key):
    rt = RescueTimeUser.get_or_none(rescuetime_key=rescuetime_key)
    if not rt:
        return HttpResponseRedirect(reverse("rt_signup"))

    data = rt.data(
        {
            "rs": "day",  # 1 day of reports
            "pv": "rank",  # perspective (rank, interval, member)
            "restrict_begin": "2010-02-11",
            "restrict_end": "2010-02-12",
        }
    )
    if "error" in data:
        error = (
            "We received an invalid RescueTime API key. Is it deactivated? <a href='%s'>Please try again</a>"
            % reverse("rt_signup")
        )
        return render_response(request, "rescuetime_interface/dashboard.html", locals())

    pledges = []
    for row in rt.procrastination_data()["rows"]:
        if rt.row_amt(row) > 0.01:
            pledges.append(
                {
                    "amt": rt.row_amt(row),
                    "hrs": rt.row_hrs(row),
                    "name": rt.row_name(row),
                    "productivity": rt.row_productivity(row),
                }
            )

    recipients = Recipient.objects.filter(fpsrecipient__status=FPSRecipient.STATUSES["SUCCESS"]).exclude(slug="PD")
    return render_response(request, "rescuetime_interface/dashboard.html", locals())
Exemple #2
0
def confirm_reset_password(request, username, confirmation_code):
    logout(request)
    tagging = RecipientUserTagging.get_or_none(user__username=username)
    error = None
    if not tagging:
        error = "Unknown username"
    #elif tagging.is_confirmed:
    #    error = "Registration is already complete."
    elif not tagging.confirm(confirmation_code):
        error = "Error confirming confirmation_code %s" % confirmation_code
    else:
        if request.POST:
            form = SetPasswordForm(tagging.user, request.POST)
            if form.is_valid():
                form.save()
                
                success = tagging.confirm(confirmation_code)
                if not success:
                    return render_response(request, 'procrasdonate/recipient_organizer_pages/account/confirmation_error.html', locals())

                user = authenticate(username=username, password=form.cleaned_data['new_password1'])
                if user.is_active:
                    login(request, user)
                    user.message_set.create(message='Password reset complete!')
                    return HttpResponseRedirect(reverse('recipient_organizer_dashboard'))                
                else:
                    return HttpResponseRedirect(reverse('login'))
        
    form = SetPasswordForm(tagging.user)
    instructions = """Enter a new password. It can be whatever you want, but it will
    be more secure if you use numbers and uppercase letters in addition to lowercase letters."""
    return render_response(request, 'procrasdonate/recipient_organizer_pages/account/confirm.html', locals())
Exemple #3
0
def payment_registration(request):
    recipient = request.user.get_profile().recipient
    substate_menu_items = _organizer_submenu(request, "receive_donations", recipient)

    errors = []
    template = 'procrasdonate/recipient_organizer_pages/payment_registration.html'

    r = FPSRecipient.get_or_none(recipient=recipient)
    if not r:
        r = FPSRecipient.add(recipient=recipient)
    
    if r.good_to_go():
        return render_response(request, template, locals())   
    
    action_url = AMAZON_CBUI_URL
    parameters = {'callerKey'         : settings.FPS['callerKey'],
                  'callerReference'   : r.caller_reference,
                  'cobrandingUrl'     : settings.FPS['cobrandingUrl'],
                  'websiteDescription': settings.FPS['websiteDescription'],
                  'pipelineName'      : "Recipient",
                  'recipientPaysFee'  : "True",
                  #'maxFixedFee'       : settings.FPS['maxFixedFee'],
                  'maxVariableFee'    : settings.FPS['maxVariableFee'],
                  'returnUrl': "%s%s" % (settings.DOMAIN,
                                         reverse('payment_registration_callback')),
                  'version': settings.FPS['version']
                  }
    # add timestampe and signature
    finalize_parameters(parameters, type=CBUI_TYPE)
    
    return render_response(request, template, locals())    
Exemple #4
0
def signup(request):
    errors = []
    if request.POST:
        rescuetime_key = request.POST.get("rescuetime_key", "")
        # recipient_slug = request.POST.get("recipient_slug", "")
        # dollars_per_hr = request.POST.get("dollars_per_hr", "")
        if not rescuetime_key:
            errors.append("Please enter a RescueTime key")
            return render_response(request, "rescuetime_interface/signup.html", locals())
        # if not recipient_slug:
        #    errors.append("Please select a charity to donate to")
        #    return render_response(request, 'rescuetime_interface/signup.html', locals())
        # if not dollars_per_hr:
        #    errors.append("Please enter how many dollars you will donate for every hour procrastinated")
        #    return render_response(request, 'rescuetime_interface/signup.html', locals())

        rt = RescueTimeUser.get_or_none(rescuetime_key=rescuetime_key)
        if not rt:
            rt = RescueTimeUser.add(rescuetime_key)

        return HttpResponseRedirect(reverse("rt_dashboard", args=(rt.rescuetime_key,)))

    return render_response(request, "rescuetime_interface/signup.html", locals())

    """        
Exemple #5
0
def render_flashcard(request, flashcard):
  result = extract_parameters(request, "GET", [], [("both", False), ("B", False)])
  if not result['success']:
    return render_response(request, 'flashcards/error.html', {'error': result['reason']})
  print result
  both_sides = smart_bool(result['parameters']['both'])
  side_B = smart_bool(result['parameters']['B'])
  return render_response(request, 'flashcards/flashcard.html', locals())
def edit_public_information(request):
    recipient = request.user.get_profile().recipient
    substate_menu_items = _organizer_submenu(request, "public", recipient)
    submenu_id = "organizer_submenu"
        
    FormKlass = get_form(Recipient, EDIT_TYPE, includes=('name',
                                                         'category',
                                                         'mission',
                                                         'description',
                                                         'url'))

    if request.POST:
        form = FormKlass(request.POST, instance=recipient)
        if form.is_valid():
            form.save()
            request.user.message_set.create(message='Changes saved')
            arrow_direction = request.POST.get("arrow_direction", None)
            if arrow_direction and arrow_direction == "prev":
                return HttpResponseRedirect(reverse('payment_registration'))
            elif arrow_direction and arrow_direction == "next":
                return HttpResponseRedirect(reverse('edit_private_information'))
            else:
                return HttpResponseRedirect(reverse('edit_public_information'))
    else:
        form = FormKlass(instance=recipient)

    return render_response(request, 'procrasdonate/recipient_organizer_pages/edit_public_information.html', locals())
def edit_media(request):
    recipient = request.user.get_profile().recipient
    substate_menu_items = _organizer_submenu(request, "media", recipient)
    submenu_id = "organizer_submenu"
    
    FormKlass = get_form(Recipient, EDIT_TYPE, includes=('logo',
                                                         'promotional_video',
                                                         'pd_experience_video'))

    if request.POST:
        form = FormKlass(request.POST, request.FILES, instance=recipient)
        if form.is_valid():
            form.save()
            request.user.message_set.create(message='Changes saved')
            arrow_direction = request.POST.get("arrow_direction", None)
            if arrow_direction and arrow_direction == "prev":
                return HttpResponseRedirect(reverse('edit_private_information'))
            elif arrow_direction and arrow_direction == "next":
                return HttpResponseRedirect(reverse('edit_promo_cards'))
            else:
                return HttpResponseRedirect(reverse('edit_media'))
    else:
        form = FormKlass(instance=recipient)

    return render_response(request, 'procrasdonate/recipient_organizer_pages/edit_media.html', locals())
Exemple #8
0
def info(request):
    #return json_success({'hello':'world'})
    user_count = User.objects.count()
    visitor_count = Visitor.objects.count()
    pledge_count = TotalRecipient.objects.count() + TotalRecipientVote.objects.count() + TotalSiteGroup.objects.count()
    donation_count = RecipientPayment.objects.count()
    return render_response(request, 'procrasdocoder/data.html', locals())
def recipient_organizer_dashboard(request):
    recipient_user_tagging = request.user.get_profile()
    recipient = recipient_user_tagging.recipient
    
    checkbox_fields = []
    for field in RecipientUserTagging.CHECKBOX_FIELDS:
        f = getattr(recipient_user_tagging, field)
        if f != RecipientUserTagging.TASK_STATES["INVISIBLE"]:
            if request.POST:
                checked = request.POST.get(field)
            else:
                checked = f == RecipientUserTagging.TASK_STATES["DONE"]
            checkbox_fields.append({'name'   : field,
                                    'checked': checked,
                                    'label'  : field,
                                    'help'   : '',
                                    'error'  : ''})

    if request.POST:
        for field in checkbox_fields:
            if field['checked']:
                setattr(recipient_user_tagging, field['name'], RecipientUserTagging.TASK_STATES["DONE"])
            else:
                setattr(recipient_user_tagging, field['name'], RecipientUserTagging.TASK_STATES["TODO"])
        recipient_user_tagging.save()
        request.user.message_set.create(message='changes saved')
        return HttpResponseRedirect(reverse('recipient_organizer_dashboard'))
    
    return render_response(request, 'procrasdonate/recipient_organizer_pages/dashboard.html', locals())
Exemple #10
0
def our_community_procrasdonations(request):
    app_name = 'procrasdonate'
    app_page = 'OurCommunity'
    page_name = 'Our Community'
    
    procrasdonations = ProcrasDonation.objects.all().order_by('time')
    return render_response(request, 'procrasdonate/our_community_procrasdonations.html', locals())
Exemple #11
0
def our_community_sites(request):
    app_name = 'procrasdonate'
    app_page = 'OurCommunity'
    page_name = 'Our Community'
    
    sites = Site.objects.all().order_by('total_time')
    return render_response(request, 'procrasdonate/our_community_sites.html', locals())
def users(request):
    users = User.objects.all()
    if request.GET:
        tos = request.GET.get('tos', None)
        if tos:
            users = users.filter(tos=True)
            
    stats_keys = [('total', 'All user objects, including inactive users'),
                  ('tos', 'Agree to terms of service'),
                  ('email', 'Provided an email address'),
                  ('authorized', 'Successfully completed Amazon authorization'),
                  ('payments', 'Made at least one payment through Amazon'),
                  ('pledges', 'Made at least one pledge (currently not calculated)')]
    stats_values = [User.objects.all().count(),
                    User.objects.filter(tos=True).count(),
                    User.objects.exclude(email=None).count(),
                    User.objects.filter(registration_done=True).count(),
                    RecipientPayment.objects.all().values('user').order_by().distinct().count(),
                    -1]
    
    version_keys = []
    version_values = []
    for M in range(0, 1):
        for m in range(3, 5):
            for x in range(0, 10):
                if m == 4 and x > 2:
                    continue
                v = "%s.%s.%s" % (M, m, x)
                c = User.objects.filter(version=v).count()
                if c:
                    version_keys.append(v)
                    version_values.append(c)

    return render_response(request, 'procrasdonate/superuser/users.html', locals())
def edit_thank_yous(request):
    recipient = request.user.get_profile().recipient
    
    substate_menu_items = _organizer_submenu(request, "thank_yous", recipient)
    submenu_id = "organizer_submenu"
    
    thank_yous = recipient.thank_yous()
    if thank_yous.count() < 3:
        for threshhold in [10, 100, 500]:
            MetaReport.add(recipient,
                           "Thanks for donating more than $%s to %s" % (threshhold, recipient.name),
                           """Thanks for donating more than $%s to %s

""" % (threshhold, recipient.name),
                           MetaReport.TYPES['THANKYOU'],
                           False,
                           datetime.datetime.now(),
                           threshhold)
            
    
    ThankYouFormSet = modelformset_factory(MetaReport, extra=(3-thank_yous.count()),
                                           max_num=3,
                                           fields=('threshhold', 'subject', 'message'))
    if request.method == 'POST':
        formset = ThankYouFormSet(request.POST, queryset=thank_yous)
        if formset.is_valid():
            formset.save()
            request.user.message_set.create(message='Changes saved')
            return HttpResponseRedirect(reverse('recipient_organizer_dashboard'))
        else:
            error = "Please correct the errors below"
    else:
        formset = ThankYouFormSet(queryset=thank_yous)
    return render_response(request, 'procrasdonate/recipient_organizer_pages/edit_thank_yous.html', locals())
Exemple #14
0
def dashboard(request):
    test_types = TestType.objects.all()
    num_dates = 7
    dates = []
    d = datetime.datetime.now()
    for i in range(0,num_dates):
        dates.append(d - datetime.timedelta(len(dates)))
    return render_response(request, 'crosstester/dashboard.html', locals())
Exemple #15
0
def add(request):
  if request.POST:
    wordA = request.POST.get("wordA", "")
    wordB = request.POST.get("wordB", "")
    wordA = wordA.strip()
    wordB = wordB.strip()
    FlashCard.add(wordA, wordB)
    return HttpResponseRedirect(reverse('add'))
  return render_response(request, 'flashcards/add.html', locals())
def recipient_splash(request, slug=None):
    big_video = "%sswf/LaptopIntro.swf" % settings.MEDIA_URL
    pd = Recipient.get_or_none(slug="PD")
    bilumi = Recipient.get_or_none(slug="bilumi")
    charities = Recipient.objects.filter(is_visible=True)
    special = Recipient.get_or_none(slug=slug)
    analytics = _get_analytics_data()
    analytics.update(locals())
    return render_response(request, 'procrasdonate/home.html', analytics)
Exemple #17
0
def waitlist(request):
    email = request.GET and request.GET.get("email", "") or ""
    is_added = request.GET and request.GET.get("is_added", "") or ""
    is_removed = request.GET and request.GET.get("is_removed", "") or ""
    email = request.POST and request.POST.get("email", email) or email
    is_added = request.POST and request.POST.get("is_added", is_added) or is_added
    is_removed = request.POST and request.POST.get("is_removed", is_removed) or is_removed
    group = request.GET and request.GET.get("group", "default") or "default"
    print group
    return render_response(request, "procrasdonate/wait_list/waitlist.html", locals())
Exemple #18
0
def confirm(request, username, confirmation_code):
    logout(request)
    tagging = RecipientUserTagging.get_or_none(confirmation_code=confirmation_code)
    error = None
    if not tagging:
        error = "Unknown confirmation code"
        Log.Log(error)
    elif tagging.user.username != username:
        error = "Something unexpected happened while confirming your registration as an organizer for %s. Please send us an email with this message" % tagging.recipient.name
        Log.Error(error)
    elif tagging.is_confirmed:
        error = "Registration is already complete."
        Log.Log(error)
    elif not tagging.confirmable(confirmation_code):
        error = "Error confirming confirmation code %s" % confirmation_code
        Log.Log(error)
    else:
        if request.POST:
            form = SetPasswordForm(tagging.user, request.POST)
            if form.is_valid():
                form.save()
                
                success = tagging.confirm(confirmation_code)
                if not success:
                    return render_response(request, 'procrasdonate/recipient_organizer_pages/account/confirmation_error.html', locals())

                user = authenticate(username=username, password=form.cleaned_data['new_password1'])
                if user.is_active:
                    login(request, user)
                    user.message_set.create(message='Registration complete!')
                    return HttpResponseRedirect(reverse('recipient_organizer_dashboard'))                
                else:
                    return HttpResponseRedirect(reverse('login'))
        
    form = tagging and SetPasswordForm(tagging.user) or None
    instructions = """<p>Welcome, %s.</p><p>Please enter a password. You can enter whatever 
    you want; for security, consider using at least 8 characters and mixing numbers with 
    lower and uppercase letters.</p>""" % username
    return render_response(request, 'procrasdonate/recipient_organizer_pages/account/confirm.html', locals())
Exemple #19
0
def settings(request, code):
    wedding = Wedding.get_or_404(code=code)
    selected = wedding.donees()
    
    not_selected = []
    for r in Recipient.objects.all():
        if not r in selected:
            not_selected.append(r)
            
    for r in RecipientVote.objects.all():
        if not r in selected:
            not_selected.append(r)
     
    return render_response(request, 'weddings/settings.html', locals())
def download_update(request):
    """
    Not called by anyone yet.
    """
    xpi_builder = XpiBuilder(settings.pathify([settings.PROJECT_PATH,
                                               'procrasdonate',
                                               'ProcrasDonateFFExtn'],
                                               file_extension=True),
                             "%s%s" % (settings.MEDIA_ROOT, 'xpi'),
                             "%s%s" % (settings.MEDIA_ROOT, 'rdf'))
    info = xpi_builder.get_update_info()
    link = info['update_link']
    hash = info['update_hash']
    return render_response(request, 'procrasdonate/extension_pages/download_xpi.html', locals())
def community(request):
    try:
        most_recent = RecipientVisit.objects.latest('dtime')
    except: # DoesNotExist
        most_recent = None
    
    most_donators = AggregateRecipient.max('total_donors')
    most_money = AggregateRecipient.max('total_amount')
    most_time = AggregateRecipient.max('total_time')
    staff_pick = StaffPick.get_random()
    tags = AggregateTag.objects.filter(time_type=Aggregate.TIME_TYPES['FOREVER'])
    
    analytics = _get_analytics_data()
    analytics.update(locals())
    return render_response(request, 'procrasdonate/community_pages/community_portal.html', analytics)
def analytics(request):
    recipient_user_tagging = request.user.get_profile()
    recipient = recipient_user_tagging.recipient
    
    year = Period.start_of_year()
    payments = RecipientPayment.objects.filter(recipient=recipient, dtime__gte=year).order_by('user')
    
    user_payments = {}
    for payment in payments:
        user = payment.user
        if not user in user_payments:
            user_payments[user] = []
        user_payments[user].append(payment)
    
    return render_response(request, 'procrasdonate/recipient_organizer_pages/analytics.html', locals())
def dashboard(request):
    alerts = []
    
    # waitlist
    alerts.append(_watch_alert(WaitList.objects, 'WaitList size'))
    
    # errors
    alerts += _log_alerts(Log.LOG_TYPES['ERROR'], 'Errors')
    alerts += _log_alerts(Log.LOG_TYPES['FAIL'], 'Failures')
    alerts += _log_alerts(Log.LOG_TYPES['WARN'], 'Warnings')
    
    # totals
    alerts += _total_alerts(TotalRecipient, '<b>recip</b>', lambda t: t.recipient.name)
    alerts += _total_alerts(TotalRecipientVote, '<b>vote</b>', lambda t: t.recipient_vote.name)
    alerts += _total_alerts(TotalSiteGroup, '<b>sgroup</b>', lambda t: t.sitegroup.host)

    return render_response(request, 'procrasdonate/superuser/dashboard.html', locals())
def register_organizer(request):
    RecipientUserTaggingForm = get_form(RecipientUserTagging, EDIT_TYPE, excludes=('user',
                                                                                   'is_confirmed',
                                                                                   'confirmation_code'))
    RecipientUserForm = get_form(RecipientUser, EDIT_TYPE, includes=('username',
                                                                     'first_name',
                                                                     'last_name',
                                                                     'email'))
    recipients = Recipient.objects.all()

    if request.POST:
        recipient_user_tagging_form = RecipientUserTaggingForm(request.POST)
        recipient_user_form = RecipientUserForm(request.POST)
        
        if recipient_user_tagging_form.is_valid() and recipient_user_form.is_valid():
            user = recipient_user_form.save()
            user.set_unusable_password()
            user.is_active = False
            user.save()
            
            fake_tagging = recipient_user_tagging_form.save(commit=False)
            tagging = RecipientUserTagging.add(user, fake_tagging.recipient, require_confirmation=True) 
            del fake_tagging

            # send email for recipient user to login
            c = Context({'user': user,
                         'recipient': tagging.recipient,
                         'site_url': "http://ProcrasDonate.com",
                         'confirmation_link': "%s" % (reverse('confirm',
                                                              args=(user.username,
                                                                    tagging.confirmation_code))),
                         'confirmation_code': tagging.confirmation_code,
                         'expiration_days': 14 })
            t = loader.get_template('procrasdonate/recipient_organizer_pages/account/confirmation_email.txt')
            tagging.send_email("Welcome to ProcrasDonate! Please complete registration for %s" % tagging.recipient.name,
                               t.render(c),
                               from_email=settings.EMAIL)
            
            request.user.message_set.create(message='RecipientUser successfully registered')
            return HttpResponseRedirect(reverse('home'))
    else:
        recipient_user_tagging_form = RecipientUserTaggingForm()
        recipient_user_form = RecipientUserForm()

    return render_response(request, 'procrasdonate/recipient_organizer_pages/account/register.html', locals())
Exemple #25
0
def our_community(request):
    app_name = 'procrasdonate'
    app_page = 'OurCommunity'
    page_name = 'Our Community'
    
    #text = u"p 5\u00A2 @diN0bot from python"
    #text = urllib.quote(text.encode('utf8'), safe='~') 
    #values = {'twitter_username': '******',
    #          'twitter_password': '******',
    #          'text': text }
    #url = "http://tipjoy.com/api/tweetpayment/"
    #print _POST(url, values)
    
    #calendar.timegm(datetime_object.timetuple()) * 1000
    procrasdonations = ProcrasDonation.objects.all()
    recipients = Recipient.objects.all()
    sites = Site.objects.all()
    return render_response(request, 'procrasdonate/our_community.html', locals())
def _edit_recipient_something(request, includes, template):
    """
    could use this but.... edit_foo's are likely to become more complicated with amazon auth and video stuff....
    """
    recipient = request.user.get_profile().recipient
        
    FormKlass = get_form(Recipient, EDIT_TYPE, includes=includes)

    if request.POST:
        form = FormKlass(request.POST, instance=recipient)
        if form.is_valid():
            form.save()
            request.user.message_set.create(message='Changes saved')
            return HttpResponseRedirect(reverse('recipient', args=(recipient.slug,)))
    else:
        form = FormKlass(instance=recipient)

    return render_response(request, template, locals())
Exemple #27
0
def dashboard(request):
    # table = rows of groups, with columns the total no. of emails registered per page
    table = []
    click_tos = Visitor.objects.all().values_list('email_page', flat=True).order_by().distinct()
    
    # construct header row
    header_row = ["Landing Page", "Total"]
    for click_to in click_tos:
        header_row.append(click_to)
    table.append(header_row)

    # construct rest of rows
    groups = Visitor.objects.all().values_list('page_group', flat=True).order_by().distinct()
    for group in groups:
        row = [group, Visitor.objects.filter(page_group=group).count()]
        for click_to in click_tos:
            row.append(Visitor.objects.filter(email_page=click_to, page_group=group).count())
        table.append(row)
        
    return render_response(request, 'adwords/dashboard.html', locals())
def logs(request):
    logs = Log.objects.all()
    parameters = []
    show_user = True
    
    if request.GET:
        selected_private_key = request.GET.get("private_key", None)
        if selected_private_key:
            logs = logs.filter(user__private_key=selected_private_key)
            parameters.append(( "private_key", selected_private_key ))
            show_user = False
        
        selected_log_type = request.GET.get("log_type", None)
        if selected_log_type:
            logs = logs.filter(log_type=selected_log_type)
            parameters.append(( "log_type", selected_log_type ))
        
        selected_detail_type = request.GET.get("detail_type", None)
        if selected_detail_type:
            logs = logs.filter(detail_type=selected_detail_type)
            parameters.append(( "detail_type", selected_detail_type ))
            
        selected_min_dtime = request.GET.get("min_dtime", None)
        if selected_min_dtime:
            d = datetime.datetime.strptime(selected_min_dtime, "%Y-%m-%d_%H:%M:%S")
            logs = logs.filter(dtime__gte=d)
            parameters.append(( "min_dtime", selected_min_dtime ))
        
        order_by = request.GET.get("order_by", None)
        if order_by:
            logs = logs.order_by(order_by)
            parameters.append(( "order_by", order_by ))
        else:
            logs = logs.order_by("-dtime")
    
    log_types = Log.objects.values_list('log_type', flat=True).distinct()
    detail_types = Log.objects.values_list('detail_type', flat=True).distinct()
    tos_users = User.objects.filter(tos=True)
    return render_response(request, 'procrasdonate/superuser/logs.html', locals())
Exemple #29
0
def login_view(request):
    next = request.GET.get('next', None)
    # Light security check -- make sure redirect_to isn't garbage.                                                                                                                
    if not next or '//' in next or ' ' in next:
        next = reverse('weddings_settings')

    username = request.POST.get('username', None)
    password = request.POST.get('password', None)
    user = authenticate(username=username, password=password)
    error = None
    if user is not None:
        if user.is_active:
            login(request, user)
            if not user.get_profile():
                Log.Error("dynamic_webpages.login_view: django user (RecipientUser) has no get_profile (RecipientUserTagging): %s" % user)
                return HttpResponseRedirect(reverse('home'))
            return HttpResponseRedirect(next)
        else:
            error = "Your account has been disabled"
    else:
        error = "Invalid username or password."
    return render_response(request, 'procrasdonate/recipient_organizer_pages/account/login.html', locals())
Exemple #30
0
def debug(request, rescuetime_key):
    rt = RescueTimeUser.get_or_none(rescuetime_key=rescuetime_key)
    if not rt:
        return HttpResponseRedirect(reverse("rt_signup"))

    a = AnalyticApiKey(rt.rescuetime_key, "ProcrasDonate")
    s = Service()

    data = s.fetch_data(
        a,
        {
            "rs": "day",  # 1 day of reports
            "pv": "rank",  # perspective (rank, interval, member)
            "restrict_begin": "2010-02-11",
            "restrict_end": "2010-02-12",
        },
    )

    dollars_per_hr = rt.dollars_per_hr
    recipient = rt.recipient

    websites = []
    for row in data["rows"]:
        if domain_re.search(row[3]):
            secs = row[1]
            amt = secs / 3600.0 * dollars_per_hr
            websites.append({"amt": amt, "hrs": secs / 3600.0, "domain": row[3]})

    payments = []
    for row in data["rows"]:
        if row[5] < 0:
            secs = row[1]
            amt = int(secs) / 3600.0 * dollars_per_hr
            payments.append({"amt": amt, "hrs": int(secs) / 3600.0, "domain": row[3]})

    return render_response(request, "rescuetime_interface/dashboard.html", locals())
def edit_weekly_blurbs(request):
    recipient = request.user.get_profile().recipient
    return render_response(request, 'procrasdonate/recipient_organizer_pages/edit_weekly_blurbs.html', locals())
def edit_yearly_newsletter(request):
    recipient = request.user.get_profile().recipient
    return render_response(request, 'procrasdonate/recipient_organizer_pages/edit_yearly_newsletter.html', locals())
Exemple #33
0
def main(request, slug):
    wedding = Wedding.get_or_404(slug=slug)
    return render_response(request, 'weddings/landing.html', locals())
def edit_promo_cards(request):
    recipient = request.user.get_profile().recipient
    substate_menu_items = _organizer_submenu(request, "promote", recipient)
    submenu_id = "organizer_submenu"
    return render_response(request, 'procrasdonate/recipient_organizer_pages/edit_promo_cards.html', locals())
Exemple #35
0
def adword_download_page(request, group):
    group = group
    is_download_page = True
    return render_response(request, 'procrasdonate/adwords/download_page.html',
                           locals())
Exemple #36
0
def adword_done(request, group):
    return render_response(request, 'procrasdonate/adwords/done_page.html',
                           locals())
def recipient_votes(request):
    recipient_votes = RecipientVote.objects.all()
    recipients = Recipient.objects.all()
    return render_response(request,
                           'procrasdonate/superuser/recipientvotes.html',
                           locals())
def register_organizer(request):
    RecipientUserTaggingForm = get_form(RecipientUserTagging,
                                        EDIT_TYPE,
                                        excludes=('user', 'is_confirmed',
                                                  'confirmation_code'))
    RecipientUserForm = get_form(RecipientUser,
                                 EDIT_TYPE,
                                 includes=('username', 'first_name',
                                           'last_name', 'email'))
    recipients = Recipient.objects.all()

    if request.POST:
        recipient_user_tagging_form = RecipientUserTaggingForm(request.POST)
        recipient_user_form = RecipientUserForm(request.POST)

        if recipient_user_tagging_form.is_valid(
        ) and recipient_user_form.is_valid():
            user = recipient_user_form.save()
            user.set_unusable_password()
            user.is_active = False
            user.save()

            fake_tagging = recipient_user_tagging_form.save(commit=False)
            tagging = RecipientUserTagging.add(user,
                                               fake_tagging.recipient,
                                               require_confirmation=True)
            del fake_tagging

            # send email for recipient user to login
            c = Context({
                'user':
                user,
                'recipient':
                tagging.recipient,
                'site_url':
                "http://ProcrasDonate.com",
                'confirmation_link':
                "%s" %
                (reverse('confirm',
                         args=(user.username, tagging.confirmation_code))),
                'confirmation_code':
                tagging.confirmation_code,
                'expiration_days':
                14
            })
            t = loader.get_template(
                'procrasdonate/recipient_organizer_pages/account/confirmation_email.txt'
            )
            tagging.send_email(
                "Welcome to ProcrasDonate! Please complete registration for %s"
                % tagging.recipient.name,
                t.render(c),
                from_email=settings.EMAIL)

            request.user.message_set.create(
                message='RecipientUser successfully registered')
            return HttpResponseRedirect(reverse('home'))
    else:
        recipient_user_tagging_form = RecipientUserTaggingForm()
        recipient_user_form = RecipientUserForm()

    return render_response(
        request,
        'procrasdonate/recipient_organizer_pages/account/register.html',
        locals())
def user(request, private_key):
    user = User.get_or_none(private_key=private_key)
    return render_response(request, 'procrasdonate/superuser/user.html',
                           locals())
Exemple #40
0
def adword_tests(request, adword_page):
    return render_response(request,
                           'procrasdonate/adwords/%s.html' % adword_page,
                           locals())
Exemple #41
0
def thankyou(request, slug, donation_type):
    return render_response(request, 'weddings/landing.html', locals())
def community_type(request, type):
    #tag = Tag.objects.get_or_none(tag=type)
    return render_response(request, 'procrasdonate/community_pages/community_rankings.html', locals())
def recipient(request, slug):
    recipient = get_object_or_404(Recipient, slug__iexact=slug)
    if recipient and recipient.slug != slug:
        return HttpResponseRedirect(reverse('recipient', args=(recipient.slug, )))
    return render_response(request, 'procrasdonate/public_recipient_pages/recipient.html', locals())