Merge branch 'master' into relaunch_ry
commit
bf5e81b9a8
|
@ -84,6 +84,19 @@ class Claim(models.Model):
|
||||||
user = models.ForeignKey(User, related_name="claim", null=False )
|
user = models.ForeignKey(User, related_name="claim", null=False )
|
||||||
status = models.CharField(max_length=7, choices= STATUSES, default='pending')
|
status = models.CharField(max_length=7, choices= STATUSES, default='pending')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def can_open_new(self):
|
||||||
|
# whether a campaign can be opened for this claim
|
||||||
|
|
||||||
|
#must be an active claim
|
||||||
|
if self.status != 'active':
|
||||||
|
return False
|
||||||
|
#can't already be a campaign
|
||||||
|
for campaign in self.campaigns:
|
||||||
|
if campaign.status in ['ACTIVE','INITIALIZED', 'SUCCESSFUL']:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
class RightsHolder(models.Model):
|
class RightsHolder(models.Model):
|
||||||
created = models.DateTimeField(auto_now_add=True)
|
created = models.DateTimeField(auto_now_add=True)
|
||||||
email = models.CharField(max_length=100, blank=True)
|
email = models.CharField(max_length=100, blank=True)
|
||||||
|
|
|
@ -1138,10 +1138,8 @@ def rh_tools(request):
|
||||||
claim.campaigns = claim.work.campaigns.all()
|
claim.campaigns = claim.work.campaigns.all()
|
||||||
else:
|
else:
|
||||||
claim.campaigns = []
|
claim.campaigns = []
|
||||||
claim.can_open_new=False if claim.work.last_campaign_status in ['ACTIVE','INITIALIZED'] else True
|
|
||||||
for campaign in claim.campaigns:
|
for campaign in claim.campaigns:
|
||||||
if campaign.status in ['ACTIVE','INITIALIZED']:
|
if campaign.status in ['ACTIVE','INITIALIZED']:
|
||||||
claim.can_open_new=False
|
|
||||||
if request.method == 'POST' and request.POST.has_key('edit_managers_%s'% campaign.id) :
|
if request.method == 'POST' and request.POST.has_key('edit_managers_%s'% campaign.id) :
|
||||||
campaign.edit_managers_form=EditManagersForm( instance=campaign, data=request.POST, prefix=campaign.id)
|
campaign.edit_managers_form=EditManagersForm( instance=campaign, data=request.POST, prefix=campaign.id)
|
||||||
if campaign.edit_managers_form.is_valid():
|
if campaign.edit_managers_form.is_valid():
|
||||||
|
@ -1149,7 +1147,7 @@ def rh_tools(request):
|
||||||
campaign.edit_managers_form = EditManagersForm(instance=campaign, prefix=campaign.id)
|
campaign.edit_managers_form = EditManagersForm(instance=campaign, prefix=campaign.id)
|
||||||
else:
|
else:
|
||||||
campaign.edit_managers_form=EditManagersForm(instance=campaign, prefix=campaign.id)
|
campaign.edit_managers_form=EditManagersForm(instance=campaign, prefix=campaign.id)
|
||||||
if claim.status == 'active' and claim.can_open_new:
|
if claim.can_open_new:
|
||||||
if request.method == 'POST' and request.POST.has_key('work') and int(request.POST['work']) == claim.work.id :
|
if request.method == 'POST' and request.POST.has_key('work') and int(request.POST['work']) == claim.work.id :
|
||||||
claim.campaign_form = OpenCampaignForm(request.POST)
|
claim.campaign_form = OpenCampaignForm(request.POST)
|
||||||
if claim.campaign_form.is_valid():
|
if claim.campaign_form.is_valid():
|
||||||
|
@ -1158,11 +1156,8 @@ def rh_tools(request):
|
||||||
new_campaign.target = D(settings.UNGLUEIT_MINIMUM_TARGET)
|
new_campaign.target = D(settings.UNGLUEIT_MINIMUM_TARGET)
|
||||||
new_campaign.save()
|
new_campaign.save()
|
||||||
claim.campaign_form.save_m2m()
|
claim.campaign_form.save_m2m()
|
||||||
claim.can_open_new=False
|
|
||||||
else:
|
else:
|
||||||
claim.campaign_form = OpenCampaignForm(data={'work': claim.work, 'name': claim.work.title, 'userid': request.user.id, 'managers_1': request.user.id})
|
claim.campaign_form = OpenCampaignForm(data={'work': claim.work, 'name': claim.work.title, 'userid': request.user.id, 'managers_1': request.user.id})
|
||||||
else:
|
|
||||||
claim.can_open_new=False
|
|
||||||
campaigns = request.user.campaigns.all()
|
campaigns = request.user.campaigns.all()
|
||||||
new_campaign = None
|
new_campaign = None
|
||||||
for campaign in campaigns:
|
for campaign in campaigns:
|
||||||
|
|
Loading…
Reference in New Issue