Пример #1
0
class Seminar(Page):
    abstract = RichTextField(_("abstract"),
            help_text=_("What the talk will be about."),
            default="", blank=True)
    seminardate = models.DateTimeField(_('Seminar date/time'), blank=True,null=True)
    speaker_name = models.CharField(max_length=255, default="tdb")
    speaker_institute = models.CharField(max_length=255, blank=True,null=True)
    speaker_picture = FileBrowseField(_("Speaker mugshot"), max_length=200, directory="speakers/", extensions=[".jpg",".png",".gif",'.jpeg',".JPEG",".JPG"], blank=True, null=True)
    speaker_biog =   RichTextField(_("biography"),
            help_text=_("This field can contain HTML and should contain a few paragraphs describing the background of the person."),
            default="", blank=True)
    speaker_link = models.URLField(help_text=_("Link to speaker's institutional page."))

    class Meta:
        db_table = 'lcogt_seminar'

    def last_name(self):
        if self.speaker_name:
            return self.speaker_name.split(' ')[-1]
        else:
            return None

    def save(self):
        slug = "seminar/{}".format(slugify(self.last_name()))
        slug_qs = Seminar.objects.exclude(id=self.id)
        self.slug = unique_slug(slug_qs, "slug", slug)
        super(Seminar, self).save()
Пример #2
0
class Profile(models.Model):
    """
    A person.
    """
    user = models.OneToOneField(User)
    mugshot = FileBrowseField(_("Mugshot"), max_length=200, directory="mugshots/", extensions=[".jpg",".png",".gif",'.jpeg'], blank=True, null=True)
    bio = RichTextField(_("biography"),
                          help_text=_("This field can contain HTML and should contain a few paragraphs describing the background of the person."),
                          default="", blank=True)
    job_title = models.CharField(_("job title"), max_length=60, blank=True, help_text=_("Example: Observatory Director"))
    research_interests = models.CharField(_("research interests"), max_length=255, blank=True, help_text=_("Comma separated list"))
    current = models.BooleanField(_("current staff"),default=True)
    scientist = models.BooleanField(_("staff scientist"), default=False)
    post_doc = models.BooleanField(_("post-doc in the science team"), default=False)
    new_institute = models.CharField(_("institute moved to"), help_text=_("Only to be used for past post-docs"), max_length=100, blank=True)

    admin_thumb_field = "mugshot"
    search_fields = ("first_name", "last_name", "bio", "job_title",)

    class Meta:
        verbose_name = _("LCO Person")
        verbose_name_plural = _("LCO People")
        db_table = 'lcogt_profile'

    @property
    def full_name(self):
        return u'%s %s' % (self.first_name, self.last_name)

    @models.permalink
    def get_absolute_url(self):
        return ("person_detail", (), {"slug": self.slug})

    def __str__(self):
        return "Profile for %s, %s" % (self.user.last_name, self.user.first_name)
Пример #3
0
class HTMLFile(models.Model):
    title = models.CharField(verbose_name=_("Title"), max_length=60)
    file = FileBrowseField(verbose_name=_("HTML File"), max_length=200)

    class Meta:
        verbose_name = _('HTML File')
        verbose_name_plural = _('HTML Files')

    def __unicode__(self):
        return self.title
Пример #4
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")
Пример #5
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
Пример #6
0
class News(models.Model):
    """
    Medium blog posts, articles and other media
    """
    headline = models.CharField(
        max_length=300,
        help_text='Title of the article, post or media clip',
    )
    outlet = models.CharField(
        max_length=300,
        help_text='Source of the article or media clip',
    )
    date = models.DateField(help_text='Publish date of the media', )
    link = models.URLField(
        max_length=500,
        help_text='URL link to the article/media clip',
    )
    excerpt = models.TextField(
        max_length=1000,
        help_text='A small extract from the article',
        blank=True,
        null=True,
    )
    author = models.CharField(
        max_length=300,
        help_text='Name of the author of this news clip',
        blank=True,
        null=True,
    )
    glyph = FileBrowseField(
        directory="images/glyphs",
        max_length=2048,
        help_text='Image associated with the article source. ' +
        'Unsure of what to use? Leave blank and ask a designer',
        null=True,
        blank=True,
    )
    featured = models.BooleanField(
        help_text='Do you want to feature this news piece on the homepage?',
        default=False,
    )
    publish_after = models.DateTimeField(
        help_text='Make this news visible only '
        'after this date and time (UTC)',
        null=True,
    )
    expires = models.DateTimeField(
        help_text='Hide this news after this date and time (UTC)',
        default=None,
        null=True,
        blank=True,
    )
    is_video = models.BooleanField(
        help_text='Is this news piece a video?',
        default=False,
        null=False,
        blank=False,
    )
    thumbnail = models.FileField(
        max_length=2048,
        help_text='Thumbnail image associated with the news piece. ' +
        'Unsure of what to use? Leave blank and ask a designer',
        upload_to=get_thumbnail_upload_path,
        null=True,
        blank=True,
    )

    objects = NewsQuerySet.as_manager()

    class Meta:
        """Meta settings for news model"""

        verbose_name = 'news article'
        verbose_name_plural = 'news'
        ordering = ('-date', )

    def __str__(self):
        return str(self.headline)