def list(self, limit: int = None, offset: int = 0, desc: bool = True) -> List[Profile]: query = self.db.session.query(Profile) if desc: query = query.order_by(Profile.desc()) else: query = query.order_by(Profile.asc()) return query.limit(limit).offset(offset).all()
def save_profile(request): profile = Profile() profile.name = request.POST["tmp_name"] profile.desc = request.POST["tmp_desc"] profile.addr = request.POST["tmp_addr"] profile.contact = request.POST["tmp_contact"] profile.receiver = request.POST["tmp_receiver"] request.session[DRAFT_PROFILE_KEY] = profile next = request.POST.get("next", '') if not next: raise Exception("No any next page") return HttpResponseRedirect(next)
def save(self, request): profile = Profile.objects.get(user=request.user) if profile is None: profile = Profile(user=request.user) profile.name = self.cleaned_data.get("name") profile.sex = self.cleaned_data.get("sex") profile.contact = self.cleaned_data.get("contact") profile.addr = self.cleaned_data.get("addr") profile.receiver = self.cleaned_data.get("receiver") #profile.city = self.getCity() #profile.website = self.cleaned_data.get("website") #profile.spacename = self.cleaned_data.get("spacename") profile.desc = self.cleaned_data.get("desc") profile.save() profileUpdated.send(sender=profile.__class__, request=request, profile=profile) return profile