当前位置: 首页>>代码示例>>Python>>正文


Python Account.get_account方法代码示例

本文整理汇总了Python中account.models.Account.get_account方法的典型用法代码示例。如果您正苦于以下问题:Python Account.get_account方法的具体用法?Python Account.get_account怎么用?Python Account.get_account使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在account.models.Account的用法示例。


在下文中一共展示了Account.get_account方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_context_data

# 需要导入模块: from account.models import Account [as 别名]
# 或者: from account.models.Account import get_account [as 别名]
 def get_context_data(self, **kwargs):
     context = super(self.__class__, self).get_context_data(**kwargs)
     account = Account.get_account(self.request)
     prayerbook = account.prayerbook
     context['account'] = account
     context['pray_in_my_praybook'] = prayerbook.pray_added(super(self.__class__, self).get_object())
     return context
开发者ID:kmvit,项目名称:prosbi,代码行数:9,代码来源:views.py

示例2: move_prayerbook_item

# 需要导入模块: from account.models import Account [as 别名]
# 或者: from account.models.Account import get_account [as 别名]
def move_prayerbook_item(request, item_id):
    if request.method == 'GET':
        account = Account.get_account(request)
        if account:
            prayer_book = account.prayerbook
            item = get_object_or_404(PrayerBookItem, pk=item_id)
            items = prayer_book.prayerbook_items.all()
            if item in items:
                direction = request.GET.get('direction', None)

                if direction == 'up' and item.index > 1:
                    prev_item = items.filter(index=item.index - 1)
                    if prev_item:
                        prev_item = prev_item[0]
                        prev_item.index = item.index
                        prev_item.save()
                        item.index = item.index - 1
                        item.save()
                        return HttpResponse(json.dumps({'status': True, 'message': u'Молитва перемещена вверх'}), 'json')

                elif direction == 'down':
                    next_item = items.filter(index=item.index + 1)
                    if next_item:
                        next_item = next_item[0]
                        next_item.index = item.index
                        next_item.save()
                        item.index = item.index + 1
                        item.save()
                        return HttpResponse(json.dumps({'status': True, 'message': u'Молитва перемещена вниз'}), 'json')

    return HttpResponse(json.dumps({'status': False, 'message': u'Молитва не перемещена'}), 'json')
开发者ID:kmvit,项目名称:prosbi,代码行数:33,代码来源:views.py

示例3: add_pray_to_prayerbook

# 需要导入模块: from account.models import Account [as 别名]
# 或者: from account.models.Account import get_account [as 别名]
def add_pray_to_prayerbook(request, pray_id):
    pray = get_object_or_404(Pray, pk=pray_id)
    account = Account.get_account(request)
    prayerbook = account.prayerbook
    item = prayerbook.add_pray(pray)
    if item:
        return HttpResponse(json.dumps({'status': True, 'message': u'Молитва добавлена в молитвослов'}), 'json')

    return HttpResponse(json.dumps({'status': False, 'message': u'Вы уже добавили эту молитву в свой молитвослов'}), 'json')
开发者ID:kmvit,项目名称:prosbi,代码行数:11,代码来源:views.py

示例4: post

# 需要导入模块: from account.models import Account [as 别名]
# 或者: from account.models.Account import get_account [as 别名]
 def post(self, request, *args, **kwargs):
     account = Account.get_account(request)
     item = super(self.__class__, self).get_object()
     if item not in account.prayerbook.prayerbook_items.all():
         return self.json_fail_response(message=u'Вы можете молитвы только из своего молитвослова')
     if 'delete' in request.POST:
         item.delete()
         return self.json_success_response(message=u'Молитва удалена')
     else:
         return self.json_fail_response(message=u'Отмена удаления')
开发者ID:kmvit,项目名称:prosbi,代码行数:12,代码来源:views.py

示例5: post

# 需要导入模块: from account.models import Account [as 别名]
# 或者: from account.models.Account import get_account [as 别名]
 def post(self, request, *args, **kwargs):
     account = Account.get_account(request)
     reminder_item = super(DeleteReminderItem, self).get_object()
     if reminder_item not in ReminderItem.objects.filter(reminder__in=account.account_reminders.all()):
         return self.json_fail_response(message=u'Вы можете удалять имена только из своего помянника')
     if 'delete' in request.POST:
         reminder_item.active = False
         reminder_item.save()
         return self.json_success_response(message=u'Имя удалено')
     else:
         return self.json_fail_response(message=u'Отмена удаления')
开发者ID:kmvit,项目名称:prosbi,代码行数:13,代码来源:views2.py

示例6: header_tag

# 需要导入模块: from account.models import Account [as 别名]
# 或者: from account.models.Account import get_account [as 别名]
def header_tag(context):
    request = context.get('request', None)
    account = Account.get_account(request)
    page = context['request'].META['PATH_INFO']
    form = AuthenticationForm()
    form.fields['username'].label = u'Email'
    form.fields['password'].label = u'Пароль'

    data = {
        'auth': request.user.is_authenticated if request else False,
        'account': account,
        'page': page,
        'login_form': form,
    }
    return data
开发者ID:kmvit,项目名称:prosbi,代码行数:17,代码来源:main_tags.py

示例7: get

# 需要导入模块: from account.models import Account [as 别名]
# 或者: from account.models.Account import get_account [as 别名]
 def get(self, request, *args, **kwargs):
     account = Account.get_account(request)
     form = ReminderForm(initial={'account': account})
     popup = render_to_string(self.template_name, RequestContext(request, {'form': form}))
     return self.json_success_response(popup=popup)
开发者ID:kmvit,项目名称:prosbi,代码行数:7,代码来源:views2.py

示例8: dispatch

# 需要导入模块: from account.models import Account [as 别名]
# 或者: from account.models.Account import get_account [as 别名]
 def dispatch(self, request, *args, **kwargs):
     account = Account.get_account(request)
     if account.anonym:
         return self.json_fail_response(message=u'Добавлять помянники могут только зарегистрированные пользователи')
     return super(AddReminder, self).dispatch(request, *args, **kwargs)
开发者ID:kmvit,项目名称:prosbi,代码行数:7,代码来源:views2.py

示例9: get_queryset

# 需要导入模块: from account.models import Account [as 别名]
# 或者: from account.models.Account import get_account [as 别名]
 def get_queryset(self):
     self.account = Account.get_account(self.request)
     return super(ReminderListView, self).get_queryset().filter(account=self.account)
开发者ID:kmvit,项目名称:prosbi,代码行数:5,代码来源:views2.py

示例10: get_initial

# 需要导入模块: from account.models import Account [as 别名]
# 或者: from account.models.Account import get_account [as 别名]
 def get_initial(self):
     account = Account.get_account(self.request)
     return {'prayerbook': account.prayerbook}
开发者ID:kmvit,项目名称:prosbi,代码行数:5,代码来源:views.py

示例11: dispatch

# 需要导入模块: from account.models import Account [as 别名]
# 或者: from account.models.Account import get_account [as 别名]
 def dispatch(self, request, *args, **kwargs):
     account = Account.get_account(self.request)
     book, created = PrayerBook.objects.get_or_create(account=account)
     if 'pk' in kwargs and str(book.id) != kwargs['pk']:
         raise Http404
     return super(PrayerBookView, self).dispatch(request, *args, **kwargs)
开发者ID:kmvit,项目名称:prosbi,代码行数:8,代码来源:views.py

示例12: get_object

# 需要导入模块: from account.models import Account [as 别名]
# 或者: from account.models.Account import get_account [as 别名]
 def get_object(self, queryset=None):
     account = Account.get_account(self.request)
     book, created = PrayerBook.objects.get_or_create(account=account)
     return book
开发者ID:kmvit,项目名称:prosbi,代码行数:6,代码来源:views.py


注:本文中的account.models.Account.get_account方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。