Пример #1
0
def item_voucher_send(request, pk):

    try:
        item_voucher = ItemVoucher.objects.get(id=int(pk))
    except ItemVoucher.DoesNotExist:
        return render(request, 'memecache/message.html', {
            'message': 'פרס לא קיים',
            'rtl': 'dir="rtl"'
        })

    if None == get_product(request.user, str(item_voucher.product.id)):
        return render(request, 'memecache/message.html', {
            'message': u'אין גישה לחנות',
            'rtl': 'dir="rtl"'
        })

    if item_voucher.customer != request.user:
        return render(request, 'memecache/message.html', {
            'message': u'זה לא הפרס שלך',
            'rtl': 'dir="rtl"'
        })

    sender_name = get_user_fullname_or_username(request.user)

    html_message = render_to_string(
        "memecache/email_voucher_use.html", {
            'ROOT_URL': kuterless.settings.SITE_URL,
            'sender_name': sender_name,
            'item_voucher': item_voucher
        })

    to_users_list = [item_voucher.shop.admin_user]

    send_html_message_to_users(u'מימוש פרס של ' + sender_name, html_message,
                               to_users_list)

    post_update_to_user(item_voucher.shop.admin_user.id,
                        u'מימוש פרס של ' + sender_name,
                        details_url=item_voucher.get_absolute_url())

    return render(request, 'memecache/message.html', {
        'message': 'הפרס נשלח למימוש',
        'rtl': 'dir="rtl"'
    })
Пример #2
0
def start_tag_following( follower_user, tag):
        
    if False == ( tag in follower_user.userprofile.followed_discussions_tags.all()):
            
        follower_user.userprofile.followed_discussions_tags.add( tag.name)
        follower_user.userprofile.save()
        
        all_users_visiabale_for_a_user_list = get_all_users_visiabale_for_a_user_list(follower_user)
#         already_following_users = []
        
#         for user in all_users_visiabale_for_a_user_list:
#             if name in user.userprofile.followed_discussions_tags.names():
#                 already_following_users.append(user)

        t = Template("""
            {{follower_user.get_full_name|default:follower_user.username}} גם התחיל/ה לעקוב אחרי {{name}}
            """)
        subject = t.render(Context({"follower_user": follower_user,
                                    "name" : tag.name}))
        
        html_message = render_to_string("coplay/user_follow_tag_email_update.html",
                                        {'ROOT_URL': kuterless.settings.SITE_URL,
                                         'follower_user': follower_user,
                                         'html_title': string_to_email_subject(subject),
                                         'details': subject,
                                         'tag': tag})

#         with open( "output.html" , "w") as debug_file:
#             debug_file.write(html_message)
            
        for user in all_users_visiabale_for_a_user_list:
            if tag in user.userprofile.followed_discussions_tags.all():
                if user.email != None and user.userprofile.recieve_updates:
                    send_html_message(subject, html_message,
                              '*****@*****.**',
                              [user.email])
                post_update_to_user(user.id, 
                                    header = string_to_email_subject(subject),
                                    content = subject, 
                                    sender_user_id = follower_user.id,  
                                    details_url = reverse('coplay:discussion_tag_list', kwargs={'pk': tag.id}))
Пример #3
0
def item_voucher_send(request, pk):
    
    try:
        item_voucher = ItemVoucher.objects.get(id = int(pk))
    except ItemVoucher.DoesNotExist:
        return render(request, 'memecache/message.html', 
                      {  'message'      :  'פרס לא קיים',
                       'rtl': 'dir="rtl"'})
        
    if None == get_product( request.user, str( item_voucher.product.id)):
        return render(request, 'memecache/message.html', 
                      {  'message'      :  u'אין גישה לחנות',
                       'rtl': 'dir="rtl"'})

    if item_voucher.customer != request.user:
        return render(request, 'memecache/message.html', 
                      {  'message'      :  u'זה לא הפרס שלך',
                       'rtl': 'dir="rtl"'})

    
    sender_name = get_user_fullname_or_username(request.user)
         
    html_message = render_to_string("memecache/email_voucher_use.html",
                                    {'ROOT_URL': kuterless.settings.SITE_URL,
                                     'sender_name': sender_name,
                                     'item_voucher': item_voucher})
    
    to_users_list = [item_voucher.shop.admin_user]
    
    send_html_message_to_users(u'מימוש פרס של ' + sender_name, html_message, to_users_list)
    
    
    post_update_to_user(item_voucher.shop.admin_user.id, u'מימוש פרס של ' + sender_name,  details_url = item_voucher.get_absolute_url())

        
    return render(request, 'memecache/message.html', 
                      {  'message'      :  'הפרס נשלח למימוש',
                       'rtl': 'dir="rtl"'})
Пример #4
0
    def test_user_update(self):
        print 'test_user_update start'
        self.assertEquals(UserUpdate.objects.count(), 0)
        d = self.create_dicussion()
         
        post_update_to_user(self.at1.id, header = 'כותרת', content = 'תוכן', discussion_id = d.id, sender_user_id = self.at2.id,  details_url = 'www.hp.com')
        
        post_update_to_user(self.at1.id, header = '3כותרת', content = '3תוכן', discussion_id = d.id, sender_user_id = self.at3.id,  details_url = 'www.hp.com')

        post_update_to_user(self.at2.id, header = '4כותרת', content = '4תוכן', discussion_id = d.id, sender_user_id = self.at3.id,  details_url = 'www.hp.com')
        
        self.assertEquals(UserUpdate.objects.count(), 3)
        for user_update in UserUpdate.objects.all():
            user_update.print_content()