Ejemplo n.º 1
0
class PartnerPage(Page):
    content = RichTextField(_("About"), default="", help_text=_('Main content'), blank=True)
    organizers = models.CharField(_("organizers names"), max_length=200, blank=True, help_text=_("Example: Jane Doe"))
    partner_logo = FileBrowseField(_("parter logo"), max_length=200, directory="edu/Partners/", extensions=[".jpg",".png",".gif",'.jpeg',".JPEG",".JPG", ".svg"], blank=True, null=True)
    partner_site = models.URLField(_("Link to partner website"), blank=True)
    organization = models.CharField(_("institution or organization"), max_length=200, blank=True, help_text=_("Where is the project based, who is running it?"))
    outputs = RichTextField(_("Outputs"), default="", help_text=_('What did they achieve and want to share?'), blank=True)
    contact = models.CharField(_("contact"), max_length=200, blank=True, help_text=_("Link to contact page or email"))
    active = models.BooleanField(_("active partner"), default=True)
    start = models.DateField(_("When did the partner start?"))
    end = models.DateField(_("When did the partner project end?"), blank=True)
    region = MultiChoiceField(_("Region"),
            choices=REGIONS,
            help_text=_("Where is your audience based?"),
            default='all',
            max_length=20)
    audience_type = MultiChoiceField(_("Audience type"),
            choices=AUDIENCES,
            help_text=_("What type of audience?"),
            default='all',
            max_length=20)

    class Meta:
        verbose_name = _("Partner info page")

    @property
    def audience_list(self):
        choices = dict(AUDIENCES)
        result = [choices[i] for i in self.audience_type]
        return result

    @property
    def region_list(self):
        choices = dict(REGIONS)
        result = [choices[i] for i in self.region]
        return result
Ejemplo n.º 2
0
class Activity(Page, Ownable):
    agerange = MultiChoiceField(
        choices=(('7', "7-11"),('11',"11-16"), ('16',"16+")),
        help_text=_("What is the age range for this activity?"),
        default='all',
        max_length=20)
    full_text = RichTextField(_("full text"),
            help_text=_("The full activity text"),
            default="", blank=True)
    goals = RichTextField(_("goals"),
        help_text=_("What are the overall aims of the activity."),
        default="", blank=True)
    summary = RichTextField(_("summary"),
        help_text=_("A catchy introductory paragraph."),
        default="", blank=True)
    observing_time = models.IntegerField(_('Observing time'),blank=True,null=True)
    archive_data = models.BooleanField(_('Archive data'),default=False)
    planning = RichTextField(_("planning"),
        help_text=_("What do you need to do in preparation."),
        default="", blank=True)
    background = RichTextField(_("background"),
        help_text=_("What background information would useful to a non-specialist."),
        default="", blank=True)
    next_steps = RichTextField(_("next steps"),
        help_text=_("What can the audience do after this activity?"),
        default="", blank=True)
    featured_image = FileBrowseField("Image", max_length=200, directory="files/", extensions=[".jpg",".png",".gif",'.jpeg',".JPEG",".JPG", ".svg"], blank=True, null=True)
    related_posts = models.ManyToManyField("self",
                                 verbose_name=_("Related activities"), blank=True)
    evaluation = RichTextField(_("evaluation"),
        help_text=_("How to ensure the goals are reached"),
        default="", blank=True)

    admin_thumb_field = "featured_image"

    class Meta:
        db_table = 'lcogt_activity'
        verbose_name = _("Activity")
        verbose_name_plural = _("Activities")
Ejemplo n.º 3
0
 def test_multichoicefield_validate_valid(self):
     field = MultiChoiceField(choices=[('valid choice',)])
     field.validate(['valid choice'], None)
Ejemplo n.º 4
0
 def test_multichoicefield_validate_invalid(self):
     field = MultiChoiceField(choices=[('valid choice',)])
     with self.assertRaises(ValidationError):
         field.validate(['invalid choice'], None)
Ejemplo n.º 5
0
 def test_multichoicefield_validate_valid(self):
     field = MultiChoiceField(choices=[("valid choice", )])
     field.validate(["valid choice"], None)