Beispiel #1
0
 def save(self, *args, **kwargs):
     if not self.pk:
         self.slug = generate_slug(Category, self.name,
                                   kwargs.get("object_channel", None))
     else:
         self.slug = generate_slug(Category, self.name, self.channel.slug)
     return super(Category, self).save(*args, **kwargs)
def foward_func(apps, schema_editor):
    Skill = apps.get_model('core', 'Skill')
    Cause = apps.get_model('core', 'Cause')
    for skill in Skill.objects.all():
        skill.slug = generate_slug(Skill, skill.name, skill.channel.slug)
        skill.save()
    for cause in Cause.objects.all():
        cause.slug = generate_slug(Cause, cause.name, cause.channel.slug)
        cause.save()
    return True
Beispiel #3
0
def foward_func(apps, schema_editor):
    Channel = apps.get_model("channels", "Channel")
    channel = Channel.objects.create(name="Rede Real Panorama", slug="rrp")

    # We freeze default channels skills and causes because
    # post_save signals are not sent from migrations
    from ovp.apps.core.models.skill import SKILLS
    from ovp.apps.core.models.cause import CAUSES

    Skill = apps.get_model("core", "Skill")
    Cause = apps.get_model("core", "Cause")

    for skill in SKILLS:
      skill = Skill.objects.create(name=skill, channel=channel)
      skill.slug = generate_slug(Skill, skill.name, skill.channel.slug)
      skill.save()

    for cause in CAUSES:
      cause = Cause.objects.create(name=cause, channel=channel)
      cause.slug = generate_slug(Cause, cause.name, cause.channel.slug)
      cause.save()


    # Create channel settings
    ChannelSetting = apps.get_model("channels", "ChannelSetting")
    ChannelSetting.objects.create(key="MAPS_API_LANGUAGE", value="pt-br", channel=channel)
    ChannelSetting.objects.create(key="CAN_CREATE_PROJECTS_WITHOUT_ORGANIZATION", value="1", channel=channel)
    ChannelSetting.objects.create(key="DISABLE_EMAIL", value="volunteerUnapplied-toOwner", channel=channel)
    ChannelSetting.objects.create(key="DISABLE_EMAIL", value="userInvited-toMemberInviter", channel=channel)
    ChannelSetting.objects.create(key="DISABLE_EMAIL", value="userInvited-toOwner", channel=channel)
    ChannelSetting.objects.create(key="DISABLE_EMAIL", value="userInvited-toOwnerInviter", channel=channel)
    ChannelSetting.objects.create(key="DISABLE_EMAIL", value="userInvitedRevoked-toMemberInviter", channel=channel)
    ChannelSetting.objects.create(key="DISABLE_EMAIL", value="userInvitedRevoked-toOwner", channel=channel)
    ChannelSetting.objects.create(key="DISABLE_EMAIL", value="userInvitedRevoked-toOwnerInviter", channel=channel)
    ChannelSetting.objects.create(key="DISABLE_EMAIL", value="userInvitedRevoked-toUser", channel=channel)
    ChannelSetting.objects.create(key="DISABLE_EMAIL", value="userJoined-toUser", channel=channel)
    ChannelSetting.objects.create(key="DISABLE_EMAIL", value="userLeft-toOwner", channel=channel)
    ChannelSetting.objects.create(key="DISABLE_EMAIL", value="userLeft-toUser", channel=channel)
    ChannelSetting.objects.create(key="DISABLE_EMAIL", value="userRemoved-toOwner", channel=channel)
    ChannelSetting.objects.create(key="DISABLE_EMAIL", value="userRemoved-toUser", channel=channel)
  def save(self, *args, **kwargs):
    creating = False

    if self.pk is not None:
      orig = Project.objects.get(pk=self.pk)
      if not orig.published and self.published:
        try:
          self.published_date = timezone.now()
          self.mailing().sendProjectPublished({'project': self})
        except:
          pass

      if not orig.closed and self.closed:
        try:
          self.closed_date = timezone.now()
          self.mailing().sendProjectClosed({'project': self})
        except:
          pass

      if not orig.canceled and self.canceled:
        self.closed_date = timezone.now()

      if not orig.deleted and self.deleted:
        self.deleted_date = timezone.now()
    else:
      # Project being created
      self.slug = generate_slug(Project, self.name)
      creating = True

    # If there is no description, take 100 chars from the details
    if not self.description:
      if len(self.details) > 100:
        self.description = self.details[0:100]
      else:
        self.description = self.details

    self.modified_date = timezone.now()

    obj = super(Project, self).save(*args, **kwargs)

    if creating:
      self.mailing().sendProjectCreated({'project': self})
      try:
        self.admin_mailing().sendProjectCreated({'project': self})
      except:
        pass

    return obj
    def save(self, *args, **kwargs):
        creating = False
        force_update = True

        if self.pk is not None:
            if not self.__orig_published and self.published:
                self.published_date = timezone.now()
                self.mailing().sendOrganizationPublished(
                    {"organization": self})

            if not self.__orig_deleted and self.deleted:
                self.deleted_date = timezone.now()
        else:
            # Organization being created
            self.slug = generate_slug(Organization, self.name)
            creating = True

        self.document = format_CNPJ(self.document)

        # If there is no description, take 100 chars from the details
        if not self.description and self.details:
            if len(self.details) > 100:
                self.description = self.details[0:100]
            else:
                self.description = self.details

        obj = super(Organization, self).save(*args, **kwargs)

        if creating:
            self.mailing().sendOrganizationCreated({"organization": self})
            try:
                self.admin_mailing().sendOrganizationCreated(
                    {"organization": self})
            except:
                pass

        return obj
Beispiel #6
0
 def save(self, *args, **kwargs):
   if not self.pk:
     self.slug = generate_slug(Cause, self.name, kwargs.get("object_channel", None))
   super(Cause, self).save(*args, **kwargs)