Esempio n. 1
0
class Project(models.Model):
    """
      Object representing a project
    """

    # The unique camelCase project name
    name = CharField(unique=True, max_length=255)

    # The project title to display
    title = CharField(max_length=255)
    subtitle = CharField(max_length=255)

    # Whether or not the project is still actively developed
    active = BooleanField()

    # The project description that is always visible
    shortDescription = CharField(max_length=4096)

    # The project description that is shown/hidden through the javascript link
    longDescription = CharField(max_length=4096)

    # The link to the source code location
    sourceUrl = URLField()

    # The link to the live URL
    liveUrl = URLField()
Esempio n. 2
0
class Repository(models.Model):
    owner = CharField(max_length=100)
    name = CharField(max_length=100)
    slug = SlugField(max_length=201)
    host_slug = SlugField(max_length=302, unique=True)
    language = CharField(max_length=100, null=True)
    html_url = URLField(null=True, max_length=400)
    homepage = URLField(null=True, max_length=400)
    watchers = PositiveIntegerField(null=True)
    created_at = DateTimeField(null=True)
    pushed_at = DateTimeField(null=True)
    description = TextField(null=True)
    extra_data = JSONField(null=True)
    last_modified = DateTimeField(auto_now=True)
    scm = CharField(max_length=100, choices=SCM_CHOICES, null=True)
    host = CharField(max_length=100, choices=HOST_CHOICES)
    private = BooleanField(default=False)

    class Meta:
        unique_together = ("owner", "name", "host")
        ordering = ['-watchers']

    def save(self, *args, **kwargs):
        self.slug = self.owner.lower() + '/' + self.name.lower()
        self.host_slug = self.host + '/' + self.slug
        if self.html_url == None or self.html_url == '':
            if self.host == 'bitbucket':
                self.html_url = 'https://bitbucket.org/%s/%s' % (self.owner,
                                                                 self.name)
            if self.host == 'github':
                self.html_url = 'https://github.com/%s/%s' % (self.owner,
                                                              self.name)

        super(Repository, self).save(*args, **kwargs)
Esempio n. 3
0
class Manga(TimeStampedModel, ReprMixin, models.Model):
    name = TextField("manga_name", null=True, blank=True)
    self_url = URLField("manga_url", max_length=1000, unique=True)
    description = TextField("manga_description")
    status = TextField("status", null=True, blank=True)
    year = TextField("year", null=True, blank=True)
    image_url = URLField("image_url", default="")
    # There can be manga with no chapters, i.e. future releases
    chapters = models.JSONField(default=dict)

    genres = ManyToManyField("Genre", related_name="mangas")

    categories = ManyToManyField("Category", related_name="mangas")

    author = ForeignKey("Author",
                        related_name="mangas",
                        on_delete=models.SET_NULL,
                        null=True,
                        blank=True)

    illustrators = ManyToManyField("Illustrator", related_name="mangas")
    screenwriters = ManyToManyField("Screenwriter", related_name="mangas")

    translators = ManyToManyField("Translator", related_name="mangas")

    technical_params = models.JSONField(default=dict)
Esempio n. 4
0
class VideoURL(Orderable):
    '''
    A video-url in a list connected to a Gallery
    '''
    gallery = models.ForeignKey(Gallery, related_name="videos")
    video_url = URLField(verbose_name=_("Video"), blank=True)
    title = models.CharField(max_length=50, default="Video")
Esempio n. 5
0
class Script(models.Model):
    id = models.BigAutoField(primary_key=True)
    name = models.TextField(unique=True)
    version = models.CharField(max_length=50, blank=True, null=True)
    tool = models.ManyToManyField(Tool)
    functions = ArrayField(base_field=models.BigIntegerField(),
                           null=True,
                           blank=True)
    wwan = models.BooleanField(default=False)
    wlan = models.BooleanField(default=False)
    bt = models.BooleanField(default=False)
    lan = models.BooleanField(default=False)
    rfid = models.BooleanField(default=False)
    nfc = models.BooleanField(default=False)
    path = models.FileField(upload_to='uploads/scripts/',
                            null=True,
                            blank=True)
    script_url = URLField(null=True, blank=True, db_column='url')
    add_time = models.DateTimeField(default=datetime.datetime.now())

    class Meta:
        managed = True
        db_table = 'script'

    def __str__(self) -> str:
        return self.name
Esempio n. 6
0
class Pokemon(models.Model):
    name = CharField(max_length=255)
    base_experience= IntegerField(null =True)
    weight = IntegerField(null =True)
    img_url = URLField(null =True)
    species = ForeignKey(Species, on_delete=models.CASCADE)
    is_legendary = BooleanField(null =True)
Esempio n. 7
0
class Coordinator(models.Model):
    '''A coordinator in one role.'''

    source = ForeignKey(Source, on_delete=models.CASCADE)
    name = CharField(max_length=64)
    email = EmailField()
    url = URLField()
Esempio n. 8
0
class Employee(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=10)
    get_data = URLField()

    def __str__(self):
        return self.name

    department = models.ForeignKey(Department,
                                   models.DO_NOTHING,
                                   blank=True,
                                   null=True)

    def get_data(self):

        bar_chart = pygal.Bar()
        bar_chart.title = self.name + '  average per quarter'

        data = defaultdict(list)
        for empSkill in EmpSkills.objects.filter(employee=self):
            data[str(empSkill.year) + " Q" + str(empSkill.quarter)].append(
                empSkill.grade)

        for key, value in data.items():
            bar_chart.add(key, numpy.mean(value))

        # Add data to chart

        return mark_safe('<img src="%s" width="750" height="550" />' %
                         (bar_chart.render_data_uri()))

    class Meta:
        managed = False
        db_table = 'employee'
Esempio n. 9
0
class Member(Model):
    """
    Member of App Team
    """
    name = CharField('memberName', max_length=256, null=False, blank=False)
    position = CharField('position', max_length=256, null=False, blank=False)
    image = URLField('imageUrl', max_length=256, null=False, blank=False)

    def __str__(self):
        return self.name
class Product(models.Model):
    product_id=models.AutoField
    name=models.CharField(max_length=50)
    price = models.IntegerField(default=0)
    image = URLField()
    description=models.CharField(max_length=300)
    category = models.CharField(max_length=50)
    pub_date=models.DateField()

    def __str__(self):
        return self.name
Esempio n. 11
0
class EmailOTPCode(models.Model):
    user = models.OneToOneField(
        settings.AUTH_USER_MODEL, unique=True,
        on_delete=models.CASCADE, verbose_name="User"
    )
    secret = CharField(max_length=32, verbose_name="Secret Key")
    callback = URLField(verbose_name="Callback")
    created = DateTimeField("Created", auto_now_add=True)

    def __str__(self):
        return self.secret
Esempio n. 12
0
class Tool(models.Model):
    id = models.BigAutoField(primary_key=True)
    name = models.CharField(max_length=50)
    version = models.CharField(max_length=50, blank=True, null=True)
    tool_url = URLField(null=True, blank=True, db_column='url')

    class Meta:
        managed = True
        db_table = 'tool'

    def __str__(self):
        return self.name + ':' + self.version
Esempio n. 13
0
class Sponsor(Model):
    """
    Sponsor details
    """
    name = CharField('sponsorName',
                     max_length=256,
                     unique=True,
                     null=False,
                     blank=False)
    image = URLField('imageUrl', max_length=256)

    def __str__(self):
        return self.name
Esempio n. 14
0
class Bookmark(Model):
    """

    """

    link = URLField(max_length=1000, null=False, blank=False, db_index=True)

    def __str__(self):
        """

        :return:
        """
        return str(self.link)
Esempio n. 15
0
class Slide(Model):
    title = CharField(max_length=255)
    description = CharField(max_length=255)
    url = URLField(blank=True)
    image = ImageField(storage=FileSystemStorage('{}/carousel/slides/'.format(MEDIA_ROOT), '{}/carousel/slides/'.format(MEDIA_URL)))
    order = PositiveIntegerField(default=0)
    active = BooleanField()
    
    def __unicode__(self):
        return self.title
    
    class Meta:
        ordering = ['order']
Esempio n. 16
0
class HomePage(Page):
    banner = RichTextField(blank=True,
                           help_text="Banner at the top of every page")
    header = RichTextField(blank=True, help_text="Hero title")
    body = RichTextField(blank=True, help_text="Description of page")
    filter_label_1 = TextField(
        blank=True, help_text="Label/Question for first set of filters")
    filter_label_2 = TextField(
        blank=True, help_text="Label/Question for second set of filters")
    filter_label_3 = TextField(
        blank=True, help_text="Label/Question for third set of filters")
    assessment_text = RichTextField(
        blank=True, help_text="Label for sleep assessment link")
    crisis_text = RichTextField(blank=True,
                                help_text="Label for sleep crisis page link")
    lookingfor = RichTextField(
        blank=True,
        help_text="Information on how to leave suggestions " +
        "and what the suggestions are for")
    alpha = RichTextField(blank=True, help_text="What is Alpha")
    alphatext = RichTextField(blank=True,
                              help_text="Why to take part in the alpha")
    footer = RichTextField(blank=True, help_text="Footer text")
    hero_image = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+',
        help_text="Max file size: 10MB. " +
        "Choose from: GIF, JPEG, PNG (but pick PNG if you have the choice)")
    video_url = URLField(blank=True,
                         help_text="URL of an introductiary youtube video")

    content_panels = Page.content_panels + [
        FieldPanel('banner', classname="full"),
        ImageChooserPanel('hero_image'),
        FieldPanel('header', classname="full"),
        FieldPanel('body', classname="full"),
        FieldPanel('video_url', classname="full"),
        FieldPanel('filter_label_1', classname="full"),
        FieldPanel('filter_label_2', classname="full"),
        FieldPanel('filter_label_3', classname="full"),
        FieldPanel('assessment_text', classname="full"),
        FieldPanel('crisis_text', classname="full"),
        FieldPanel('lookingfor', classname="full"),
        FieldPanel('alpha', classname="full"),
        FieldPanel('alphatext', classname="full"),
        FieldPanel('footer', classname="full"),
    ]
Esempio n. 17
0
class LiveEmbedEvent(Model):
    """
    This is an event not inherited from BaseEvent because it doesn't need some
    required attributes, in the future this app can be refactored and we can
    change BaseEvent to a more minimal version.
    This events will be used for the metadata needed to display a live event
    embeded in a page of our site.
    """
    active = BooleanField(u'activo', default=False)
    access_type = CharField(u'acceso al evento',
                            max_length=1,
                            choices=LIVE_EMBED_EVENT_ACCESS_TYPES,
                            default='s')
    in_home = BooleanField(u'agregar a portada', default=False)
    notification = BooleanField(u'mostrar notificación en artículos',
                                default=False)
    notification_text = CharField(u'texto',
                                  max_length=255,
                                  null=True,
                                  blank=True)
    notification_url = URLField(u'url', null=True, blank=True)
    title = CharField(u'título', max_length=255)
    embed_content = TextField(u'contenido incrustado', blank=True, null=True)
    embed_chat = TextField(u'chat incrustado', blank=True, null=True)

    def is_free(self):
        return self.access_type == u'f'

    def clean(self):
        from django.core.exceptions import ValidationError
        active_now = LiveEmbedEvent.objects.filter(active=True)
        if self.active:
            if (active_now.exclude(id=self.id) if self.id else active_now):
                # Don't allow more than one active instance
                raise ValidationError(
                    u'Only one event can be active at the same time.')
            if not self.embed_content:
                raise ValidationError(
                    u'Embed content should be set if the event is active.')

    def save(self, *args, **kwargs):
        self.full_clean()  # calls self.clean() as well cleans other fields
        return super(LiveEmbedEvent, self).save(*args, **kwargs)

    def __unicode__(self):
        return self.title

    class Meta:
        verbose_name = u'evento en vivo'
        verbose_name_plural = u'eventos en vivo'
Esempio n. 18
0
class Department(Model):
    name = CharField('name',
                     max_length=255,
                     null=False,
                     unique=True,
                     primary_key=True)
    password = CharField('password',
                         max_length=128,
                         null=False,
                         blank=False,
                         help_text='Leave empty if no change needed')
    image = URLField('image')

    def __str__(self) -> str:
        return "Department/Club: " + self.name
Esempio n. 19
0
class Project(models.Model):
    image = models.ForeignKey(
        'wagtailimages.Image', null=True, on_delete=models.SET_NULL)
    title = models.CharField(max_length=40)
    description = RichTextField()
    carousel_images = StreamField([
        ('image', ImageChooserBlock()),
        ('video', EmbedBlock())
    ], null=True, blank=True)
    website_url = URLField(null=True)
    discord_url = URLField(null=True)
    youtube_url = URLField(null=True)

    def __str__(self):
        return self.title
    panels = [
        ImageChooserPanel('image'),
        FieldPanel('title'),
        FieldPanel('description'),
        StreamFieldPanel('carousel_images'),
        FieldPanel('website_url'),
        FieldPanel('discord_url'),
        FieldPanel('youtube_url')
    ]
Esempio n. 20
0
class Manga(BaseModel):
    NAME_FIELD = "title"

    title = TextField(null=True, blank=True)
    alt_title = TextField(null=True, blank=True)
    self_url = URLField(max_length=1000, unique=True)
    description = TextField()
    status = TextField(null=True, blank=True)
    year = TextField(null=True, blank=True)
    image_url = URLField("thumbnail url", default="")
    # There can be manga with no chapters, i.e. future releases
    chapters = models.JSONField(default=dict)

    genres = ManyToManyField("Genre", related_name="mangas")

    categories = ManyToManyField("Category", related_name="mangas")

    author = ForeignKey("Author",
                        related_name="mangas",
                        on_delete=models.SET_NULL,
                        null=True,
                        blank=True)

    technical_params = models.JSONField(default=dict)
Esempio n. 21
0
class Card(Model):

    class Meta:
        ordering = ["card_no"]

    card_no = IntegerField(blank=True, null=True)
    card_set = ForeignKey(CardSet)
    name = CharField(max_length=255)
    url = URLField()
    card_type = ForeignKey(CardType)
    rarity = ForeignKey(Rarity)

    @property
    def instances(self):
        return self.cardinstance_set.all().order_by("variant")
Esempio n. 22
0
class About(models.Model):

    title = CharField(max_length=1000, blank=True, default="")
    subtitle = CharField(max_length=1000, blank=True, default="")
    info = TextField(blank=True, default="")

    index = IntegerField(default=0)

    externURL = URLField(verbose_name="Extern link", default="", blank=True)

    image = ImageField(upload_to="about_images", null=True)

    largeImage = ImageSpecField(source="image",
                                processors=[ResizeToFill(1920, 1080)],
                                format='JPEG',
                                options={
                                    'quality': 75,
                                    'progressive': True
                                })

    mediumImage = ImageSpecField(source="image",
                                 processors=[ResizeToFill(1280, 720)],
                                 format='JPEG',
                                 options={
                                     'quality': 75,
                                     'progressive': True
                                 })

    smallImage = ImageSpecField(source="image",
                                processors=[ResizeToFill(640, 360)],
                                format='JPEG',
                                options={
                                    'quality': 75,
                                    'progressive': True
                                })

    def getShortDescription(self):
        return str(self.title + " - " + self.subtitle[:50] + "...")

    def toHTML(self):
        return self.info.replace("<p", "<p class=\"rl-document__paragraph\"")\
            .replace("<span", "<span class=\"rl-document__title\"")

    def __unicode__(self):
        return self.title + " - " + self.subtitle
Esempio n. 23
0
class Event(Model):
    """
    Event
    """
    # choices = (
    #     (0, "DepartmentEvent"),
    #     (1, "InstituteEvent"),
    #     (2, "Talk"),
    #     (3, "Exhibition"),
    #     (4, "Workshop")¸
    # )
    name = CharField('EventName', max_length=256)
    info = CharField('info', max_length=256)
    platform = CharField('platform', max_length=256)
    date = DateTimeField('date')
    image = URLField('imageUrl', max_length=256)
    abstract = TextField('abstract', max_length=1000)
    type = IntegerField('type')

    def __str__(self):
        return self.name
Esempio n. 24
0
class Task(models.Model):
    id = models.BigAutoField(primary_key=True)
    uut = models.ForeignKey('iur.Uut',
                            on_delete=models.CASCADE,
                            null=True,
                            blank=True)
    uut_uuid = models.UUIDField(null=True, blank=True)
    group_uuid = models.UUIDField()
    group_series = models.BigIntegerField(null=False, blank=False)
    group_name = models.CharField(max_length=50, blank=True, null=True)
    group_task_series = models.BigIntegerField(blank=True, null=True)
    script = models.ForeignKey(Script, on_delete=models.CASCADE, null=False)
    status = models.ForeignKey(TaskStatus,
                               on_delete=models.CASCADE,
                               null=False)
    ap = models.ForeignKey(Ap, on_delete=models.CASCADE, blank=True, null=True)
    assigner = models.ForeignKey(User,
                                 on_delete=models.CASCADE,
                                 null=True,
                                 blank=True)
    uut_info = JSONField(blank=True, null=True)
    power_cycle_info = JSONField(default={}, null=True)
    start_time = models.DateTimeField(blank=True, null=True)
    finish_time = models.DateTimeField(blank=True, null=True)
    add_time = models.DateTimeField(auto_now_add=True)
    tool = models.ForeignKey(Tool,
                             on_delete=models.CASCADE,
                             null=True,
                             blank=True)
    connection_type = models.CharField(max_length=20, blank=True, null=True)
    # ssid = models.TextField(blank=True,null=True)
    log = URLField(blank=True, null=True)

    class Meta:
        managed = True
        db_table = 'uut_task'  # This is an auto-generated Django model module.
        unique_together = ['group_task_series', 'group_uuid']

    def __str__(self) -> str:
        return f'{self.id} - {self.uut} - {self.group_name} - {self.script} {self.status}'
Esempio n. 25
0
class Buttons(models.Model):
    BUTTON_TYPES = (('Primary', 'Primary'), ('Secondary', 'Secondary'))
    button_type = CharField(choices=BUTTON_TYPES,
                            default='Primary',
                            max_length=16,
                            help_text='Type of Button - Primary/Secondary')
    button_text = TextField()
    button_link = URLField()

    ALIGNMENT_CHOICES = (('tl', 'left'), ('tc', 'center'), ('tr', 'right'))
    alignment = CharField(choices=ALIGNMENT_CHOICES,
                          max_length=10,
                          default='left',
                          help_text='Alignment of the button')

    panels = [
        FieldPanel('button_type'),
        FieldPanel('button_text'),
        FieldPanel('button_link'),
        FieldPanel('alignment')
    ]

    class Meta:
        abstract = True
Esempio n. 26
0
class RepositoryUser(models.Model):
    login = CharField(max_length=100, db_index=True)
    name = CharField(max_length=100, null=True)
    slug = SlugField(max_length=201, unique=True)
    email = EmailField(max_length=254, null=True)
    blog = URLField(null=True)
    followers = PositiveIntegerField(null=True)
    following = PositiveIntegerField(null=True)
    public_repos = PositiveIntegerField(null=True)
    created_at = DateTimeField(null=True)
    extra_data = JSONField(null=True)
    last_modified = DateTimeField(auto_now=True)
    repositories = models.ManyToManyField(
        Repository, through='RepositoryUserRepositoryLink')
    starred = PositiveIntegerField(null=True)
    watched = PositiveIntegerField(null=True)
    host = CharField(max_length=100, choices=HOST_CHOICES, db_index=True)

    class Meta:
        unique_together = ("login", "host")

    def save(self, *args, **kwargs):
        self.slug = self.host + '/' + self.login.lower()
        super(RepositoryUser, self).save(*args, **kwargs)
Esempio n. 27
0
 def test_URLField(self):
     lazy_func = lazy(lambda: 'http://domain.com', six.text_type)
     self.assertIsInstance(URLField().get_prep_value(lazy_func()),
                           six.text_type)
Esempio n. 28
0
 def test_URLField(self):
     self.assertIsInstance(URLField().get_prep_value('http://domain.com'),
                           six.text_type)
Esempio n. 29
0
class RelatedContent(ContentModel):
    url = URLField(blank=True, null=True)
    is_video = BooleanField(default=False)
    does_continue = BooleanField(default=False)
Esempio n. 30
0
class ResourcePage(AbstractForm):
    def process_form_submission(self, request_dict):
        return custom_form_submission(self, request_dict)

    def serve(self, request, *args, **kwargs):
        try:
            request_dict = request.POST.dict()

            id = request_dict['id']

            self.process_form_submission(request_dict)

            try:
                cookie = request.COOKIES['ldmw_session']
            except:
                cookie = uid.hex

            resource = get_resource(id, cookie)

            if request_dict['feedback'] == '':
                error = True
            else:
                error = False

            csrf = request.POST.get('csrfmiddlewaretoken')

            resource_result = render_to_string(
                'resources/resource.html', {
                    'page': resource,
                    'like_feedback_submitted': True,
                    'error': error,
                    'csrf_token': csrf
                })

            visited_result = render_to_string(
                'resources/single_visited.html', {
                    'v': resource,
                    'like_feedback_submitted': True
                })

            return JsonResponse({
                'result': resource_result,
                'visited_result': visited_result,
                'id': id,
                'feedback': True
            })

        except:
            request.is_preview = getattr(request, 'is_preview', False)

            return TemplateResponse(
                request, self.get_template(request, *args, **kwargs),
                self.get_context(request, *args, **kwargs))

    form_fields = None

    heading = TextField(blank=True,
                        help_text="The title of the resource being linked to")
    logo_background_color = RGBColorField(
        default='#16b28f',
        null=True,
        blank=True,
        help_text="The background colour of brand_logo")
    resource_url = URLField(blank=True,
                            help_text="The url of the resource to link to")
    resource_url_text = TextField(blank=True,
                                  help_text="The text for the url link")
    tagline = RichTextField(
        blank=True, help_text="Bold text that displays on the resource list")
    body = StreamField([
        ('rich_text', blocks.RichTextBlock()),
        ('rawhtml', blocks.RawHTMLBlock()),
        ('heading', blocks.RichTextBlock()),
        ('paragraph', blocks.RichTextBlock()),
        ('column_left', blocks.RichTextBlock()),
        ('column_right', blocks.RichTextBlock()),
        ('image', ImageChooserBlock()),
    ])
    pros = RichTextField(blank=True,
                         help_text="A list of pros for the resource")
    cons = RichTextField(blank=True,
                         help_text="A list of cons for the resource")
    topic_tags = ClusterTaggableManager(
        through=TopicTag,
        blank=True,
        verbose_name='Topic Tags',
        related_name='resource_topic_tags',
        help_text='Topic tags, eg: "sleep", "depression", "stress"')
    issue_tags = ClusterTaggableManager(
        through=IssueTag,
        blank=True,
        verbose_name='Issue Tags',
        related_name='resource_issue_tags',
        help_text='Issue tags, eg: "insomnia", "fatigue", "snoring"')
    reason_tags = ClusterTaggableManager(
        through=ReasonTag,
        blank=True,
        verbose_name='Reason Tags',
        related_name='resource_reason_tags',
        help_text='Reason tags, eg: "loneliness", "relationships"')
    content_tags = ClusterTaggableManager(through=ContentTag,
                                          blank=True,
                                          verbose_name='Content Tags',
                                          related_name='resource_content_tags',
                                          help_text="""
            Content Type tags, eg: "videos", "blogs", "free", "subscription"
        """)
    hidden_tags = ClusterTaggableManager(through=HiddenTag,
                                         blank=True,
                                         verbose_name='Hidden Tags',
                                         related_name='resource_hidden_tags',
                                         help_text='Hidden tags for admin use')
    PRIORITY_CHOICES = (
        (1, '1'),
        (2, '2'),
        (3, '3'),
        (4, '4'),
        (5, '5'),
    )
    priority = IntegerField(choices=PRIORITY_CHOICES,
                            default='5',
                            help_text='Highest priority 1, lowest priority 5')
    background_color = RGBColorField(
        default='#ffffff',
        null=True,
        blank=True,
        help_text="The background colour to use if there is no hero image")
    hero_image = models.ForeignKey('wagtailimages.Image',
                                   null=True,
                                   blank=True,
                                   on_delete=models.SET_NULL,
                                   related_name='+',
                                   help_text="""
            Max file size: 10MB. Choose from: GIF, JPEG, PNG
            (but pick PNG if you have the choice)
        """)
    brand_logo = models.ForeignKey('wagtailimages.Image',
                                   null=True,
                                   blank=True,
                                   on_delete=models.SET_NULL,
                                   related_name='+',
                                   help_text="""
            Max file size: 10MB. Choose from: JPEG, PNG
            (Please upload 155x60 image)
        """)
    brand_text = RichTextField(blank=True)
    text_color = RGBColorField(default='#000000',
                               null=True,
                               blank=True,
                               help_text="""
            The colour of the brand text.
            It should contrast well with the background colour or image
        """)
    latitude = LatitudeField(blank=True,
                             max_length=255,
                             help_text="""
            latitude. This should be a number between -90 and 90
        """)
    longitude = LongitudeField(blank=True,
                               max_length=255,
                               help_text="""
            longitude. This should be a number between -180 and 180
        """)

    search_fields = Page.search_fields + [
        index.SearchField('body'),
        index.SearchField('pros'),
        index.SearchField('cons'),
        index.SearchField('heading'),
        index.SearchField('resource_url'),
        index.RelatedFields('issue_tags', [
            index.SearchField('name'),
        ]),
        index.RelatedFields('content_tags', [
            index.SearchField('name'),
        ]),
        index.RelatedFields('reason_tags', [
            index.SearchField('name'),
        ]),
    ]

    content_panels = Page.content_panels + [
        MultiFieldPanel([
            ImageChooserPanel('hero_image'),
            FieldPanel('background_color'),
            ImageChooserPanel('brand_logo'),
            FieldPanel('brand_text'),
            FieldPanel('text_color')
        ],
                        heading="Branding"),
        InlinePanel('badges', label="Badge"),
        InlinePanel('latlong', label="Latitude and Longitude"),
        FieldPanel('heading', classname="full"),
        FieldRowPanel([
            FieldPanel('logo_background_color', classname="col6"),
        ],
                      classname="full"),
        FieldRowPanel([
            FieldPanel('resource_url', classname="col6"),
            FieldPanel('resource_url_text', classname="col6"),
        ],
                      classname="full"),
        FieldPanel('tagline', classname="full"),
        StreamFieldPanel('body'),
        InlinePanel('buttons', label="Buttons"),
        FieldPanel('pros', classname="full"),
        FieldPanel('cons', classname="full")
    ]

    promote_panels = Page.promote_panels + [
        FieldPanel('topic_tags'),
        FieldPanel('issue_tags'),
        FieldPanel('reason_tags'),
        FieldPanel('content_tags'),
        FieldPanel('hidden_tags'),
        FieldPanel('priority'),
    ]

    def __init__(self, *args, **kwargs):
        self.__class__.objects.prefetch_related('tagged_items__tag')
        super(ResourcePage, self).__init__(*args, **kwargs)
        try:
            self.parent = self.get_parent().slug
        except:
            self.parent = None

    def get_context(self, request):
        context = super(ResourcePage, self).get_context(request)

        if (request.META.get('HTTP_REFERER')
                and request.session.get('results_page')):
            context['back'] = request.session.pop('results_page')

        if 'ldmw_session' in request.COOKIES:
            cookie = request.COOKIES['ldmw_session']
            try:
                context['liked_value'] = Likes.objects\
                    .get(resource_id=self.id, user_hash=cookie)\
                    .like_value
            except:
                context['liked_value'] = 0
        else:
            cookie = ''
            context['liked_value'] = 0

        if 'ldmw_location_latlong' in request.COOKIES:
            try:
                location = request.COOKIES['ldmw_location_latlong']
                [user_lat, user_long] = location.split(",")
                context['is_near'] = any(
                    filter(
                        lambda e: haversine_distance(float(
                            user_lat), float(user_long), float(
                                e.latitude), float(e.longitude)) / 1.6 < 1000,
                        self.latlong.all()))
                # less than 1 mile
            except:
                print("Failed to get location")
                context['is_near'] = False
        else:
            context['is_near'] = False

        Home = apps.get_model('resources', 'home')

        combine_tags = create_tag_combiner(None)
        landing_pages = Home.objects.filter(~Q(slug="home")).live()

        context['landing_pages'] = landing_pages
        context['tags'] = combine_tags(self).specific.tags
        context['number_of_likes'] = Likes.objects\
            .filter(resource_id=self.id, like_value=1)\
            .count()
        context['number_of_dislikes'] = Likes.objects\
            .filter(resource_id=self.id, like_value=-1)\
            .count()
        context['badges'] = ResourcePageBadges.objects\
            .filter(page_id=self.page_ptr_id)
        context['buttons'] = ResourcePageButtons.objects\
            .filter(page_id=self.page_ptr_id)

        return base_context(context, self)

    def get_form_fields(self):
        return iter([])

    def likes(self):
        return Likes.objects\
            .filter(resource_id=self.id, like_value=1)\
            .count()

    def dislikes(self):
        return Likes.objects\
            .filter(resource_id=self.id, like_value=-1)\
            .count()

    class Meta:
        verbose_name = "Resource"