예제 #1
0
파일: views.py 프로젝트: alexkau/YACP
def selections(request, id=None, version=None, ext=None):
    #print request.POST
    if request.method == 'GET' and request.user \
                                and request.user.is_authenticated() \
                                and request.user.planuser.selections:
        selection = request.user.planuser.selections
        return {'context': selection.toJSON()}
    elif request.method == 'GET' and id:
        selection = SavedSelection.objects.get(id=id)
        return {'context': selection.toJSON()}

    if request.method != 'POST':
        raise decorators.AlternativeResponse(
            HttpResponseBadRequest('{}')
        )

    section_ids = int_list(request.POST.get('section_ids', '').split(','))
    blocked_times = request.POST.get('blocked_times', '').split(',')
    serialized = request.POST.get('serialized', '')

    internal_section_ids = serialize_numbers(section_ids)
    internal_blocked_times = request.POST.get('blocked_times')

    selection, created = SavedSelection.objects.get_or_create(
        internal_section_ids=internal_section_ids,
        internal_blocked_times=internal_blocked_times,
        internal_serialized=serialized,
    )

    if request.user and request.user.is_authenticated():
        request.user.planuser.selections = selection
        request.user.planuser.save()
    return {'context': selection.toJSON()}
예제 #2
0
파일: managers.py 프로젝트: gpnoel/YACS
    def _update_kwargs(self, kwargs):
        if 'section_ids' in kwargs:
            section_ids = serialize_numbers(kwargs.pop('section_ids'))
            kwargs['internal_section_ids'] = section_ids or []

        if 'slug' in kwargs:
            kwargs['internal_slug'] = kwargs.pop('slug')
        return kwargs
예제 #3
0
파일: managers.py 프로젝트: Radzell/YACS
    def _update_kwargs(self, kwargs):
        if 'section_ids' in kwargs:
            section_ids = serialize_numbers(kwargs.pop('section_ids'))
            kwargs['internal_section_ids'] = section_ids or []

        if 'slug' in kwargs:
            kwargs['internal_slug'] = kwargs.pop('slug')
        return kwargs
예제 #4
0
파일: models.py 프로젝트: Radzell/YACS
 def section_ids(self, section_ids):
     self.internal_section_ids = serialize_numbers(section_ids)
예제 #5
0
파일: models.py 프로젝트: uyenuong/YACS
 def section_ids(self, section_ids):
     self.internal_section_ids = serialize_numbers(section_ids)