我的问题是很长时间的,因为我对良好方案拟订做法,特别是詹戈缺乏了解。 我赞赏任何建议。
www.un.org/Depts/DGACM/index_spanish.htm 模型(简化)
class Customer(models.Model):
# Customer info
first_name = models.CharField(max_length=75)
last_name = models.CharField(max_length=179, null=True, blank=True)
# ... and more fields that need validation but not needed for the question
pay_method = models.CharField(max_length=1, choices=PAY_METHODS)
bank_code = models.CharField(max_length=4, blank=True, null=True)
bank_office_code = models.CharField(max_length=4, blank=True, null=True)
bank_control_digit = models.CharField(max_length=2, blank=True, null=True)
bank_account_number = models.CharField(max_length=10, blank=True, null=True)
class Product(models.Model):
name = models.CharField(max_length=50)
class Subscription(models.Model):
customer = models.ForeignKey(Customer)
product = models.ForeignKey(Product)
user = models.OneToOneField(User)
# ...
start_date = models.DateField(null=True)
end_date = models.DateField(null=True)
# ...
is_main_subscription = models.BooleanField(default=False)
class Invoice(models.Model):
customer = models.ForeignKey(Customer)
subscriptions = models.ManyToManyField(Subscription,null=True,blank=True)
#...
www.un.org/Depts/DGACM/index_spanish.htm 问题
有两个非常相似的订阅过程。 一个是新用户,另一个是现有用户。
对于新用户来说,订阅过程涉及填写客户的个人数据和在客户表格中支付信息,并至少设定一个说明。 每一处都指产品。 这一过程结束时,产生了对所有这些说明的发票。 我认为,这里不必采用“发票”模式,但我认为,如果该模式有用的话,我会在这里这样做。 每一处都设有一个连接网关的用户。
第一个说明是主要订阅<>。 与这一规定相关的用户可以延长或取消其他订阅,并购买新的订阅。 这一新过程涉及在必要时改变付款信息,但没有客户的个人数据。 我们必须区分新的规定。
<>>Forms
客户一号为三种模式:
支付 表格仅供用户在订阅过程中使用。
class PaymentForm(forms.ModelForm):
class Meta:
model = Customer
fields = (
pay_method ,
bank_code ,
bank_office_code ,
bank_control_digit ,
bank_account_number
)
# ...
DataForm is used alone for logged in users whose subscription is the main subscription to edit the Customer personal info out of the subscription process.
class DataForm(forms.ModelForm):
class Meta:
model = Customer
fields = (
first_name ,
last_name ,
# All the other fields
)
# ...
NewCustomer 表格为我设计了一种组合支付表格和数据表格的形式。
class NewCustomerForm(MyDataForm, PaymentForm):
class Meta:
model = Customer
fields = MyDataForm.Meta.fields + PaymentForm.Meta.fields
说明 我认为,应该有两种形式(在线表格):
- RenewalsFormSet: For logged in users to cancel or renew existing subscriptions. User can t edit info, only cancel or renew.
- SubscriptionsFormSet: For logged and not logged in users, to add new subscriptions.
How could I handle both cases in the simplest way? The new subscriptions formset must not have knowledge of existing subscriptions.
www.un.org/Depts/DGACM/index_spanish.htm 问题在于。
从Django的观点来看,订阅过程是:
- GET form view: Forms are presented to the user.
- POST forms: Forms are validated. If error: go to point 1. If success: save POST data in the session.
- GET confirmation view: Summary of products to be purchased.
- GET confirm payment: Depending of the pay method selected the process here may vary.
- GET thankyou page
What can I do to have a single subscription process for both logged and not logged in users?
我曾想到某种物体,如一个黑色箱,接收客户(根据用户是否已经登记)的投入和回报,所有用户都愿意储存在数据库中。
但我不知道如何这样做。
(如果你看上去,你必须非常 n。) 感谢!