Exemple #1
0
class MarketingBanner(cms.Model, models.Model):
	"""
	Model for holding Marketing Banner images

	Height and width fields are prepopulated with our standard,
	but not enforced by the model.

	Each Marketing Banner may individually be activated or deactivated,
	regardless of its group membership.

	"""
	
	qa_objects = cms.QAManager()
	objects = cms.Manager()
	all_objects = models.Manager()
	
	for_update = models.PositiveSmallIntegerField(default=2, editable=False)
	active = models.CharField(max_length=1, default=u'1', choices=cms.Model.ACTIVE, help_text="Select Inactive to remove this Marketing Banner from display on the site.")
	name = models.CharField(max_length=50, help_text="Please enter a name for this Marketing Banner.")
	image = models.ImageField(width_field='', height_field='', upload_to='db/marketing_banners/%Y/%m/%d')
	date_added = models.DateField(auto_now_add=True)
	link = models.ForeignKey(Resource, help_text="Select the resource that this banner links to.")
	
	def __unicode__(self):
		return self.name
	
	class Meta:
		verbose_name = "Marketing Banner"
		verbose_name_plural = "Marketing Banners"
Exemple #2
0
class MediaFile(cms.Model, models.Model):
    """
	Model for a media library.
		
	"""

    qa_objects = cms.QAManager()
    objects = cms.Manager()
    all_objects = models.Manager()

    for_update = models.PositiveSmallIntegerField(default=2, editable=False)
    active = models.CharField(max_length=1,
                              default=u'1',
                              choices=cms.Model.ACTIVE,
                              editable=False)
    category = models.ForeignKey(MediaCategory,
                                 help_text="Select a category for this file.")
    name = models.CharField(max_length=50,
                            help_text="Enter a name for this file.")
    description = models.CharField(
        max_length=200,
        blank=True,
        help_text="Enter an optional description for this file.")
    mediafile = models.FileField(
        upload_to='db/media-library',
        help_text="File to upload to the media library.")

    def __unicode__(self):
        return u'%s' % (self.mediafile)

    def get_absolute_url(self):
        return self.get_mediafile_url()
Exemple #3
0
class Link_Nav(cms.Model, models.Model):
    """
	Model for resource links associated with this doctor
	"""

    qa_objects = cms.QAManager()
    objects = cms.Manager()
    all_objects = models.Manager()

    for_update = models.PositiveSmallIntegerField(default=2, editable=False)
    active = models.CharField(
        max_length=1,
        default=u'1',
        choices=cms.Model.ACTIVE,
        help_text=
        "Select Inactive to remove this item from display and search on the site."
    )
    resource = models.ForeignKey(site.Resource,
                                 related_name='doctor_resource_nav')
    doctor = models.ForeignKey(Doctor)
    position = models.PositiveSmallIntegerField(max_length=2)

    class Meta:
        ordering = ['resource']
        verbose_name = "Link for nav display"
        verbose_name_plural = "Links for nav display"

    def __unicode__(self):
        return u'%s (%s)' % (self.doctor, self.resource)
Exemple #4
0
class MBGroup(cms.Model, models.Model):
	"""
	Model for Marketing Banner Groups

	There is a many-to-many relationship:
	A single MarketingBanner may belong to zero or more MBGroups,
	and each MBGroup may hold zero or more MarketingBanners.

	Each MBGroup may individually be activated or deactivated,
	regardless of the settings of its member MarketingBanners.

	"""
	
	qa_objects = cms.QAManager()
	objects = cms.Manager()
	all_objects = models.Manager()
	
	for_update = models.PositiveSmallIntegerField(default=2, editable=False)
	active = models.CharField(max_length=1, default=u'1', choices=cms.Model.ACTIVE, help_text="Select Inactive to remove this Marketing Group from display and search on the site.")
	name = models.CharField(max_length=50, help_text="Please enter a name for this Group of Marketing Banners")
	banners = models.ManyToManyField(MarketingBanner, blank=True, null=True, verbose_name="Select a list of Marketing Banners")
	start_date = models.DateField(blank=True, null=True, help_text="You may enter an optional date on which to start display of this group.")
	end_date = models.DateField(blank=True, null=True, help_text="You may enter an option date on which to end display of this group.")
	urls = models.TextField(help_text="Enter one or more local URLs (e.g. 'service/cardiology') under which this marketing banner will be displayed. Enter one URL per line.")

	def __unicode__(self):
		return self.name

	class Meta:
		verbose_name = "Marketing Banner Group"
		verbose_name_plural = "Marketing Banner Groups"
Exemple #5
0
class URLAlias(cms.Model, models.Model):
    """
	Model for URL Aliases
	"""
    qa_objects = cms.QAManager()
    objects = cms.Manager()
    all_objects = models.Manager()

    for_update = models.PositiveSmallIntegerField(default=2, editable=False)
    active = models.CharField(
        max_length=1,
        default=u'1',
        choices=cms.Model.ACTIVE,
        help_text="Select Inactive to remove this URL alias.")
    urlname = models.CharField(
        max_length=50,
        unique=True,
        help_text="Enter identifier for this alias URL (e.g. 'cardiology')")

    class Meta:
        ordering = ['urlname']
        verbose_name = "URL Alias"
        verbose_name_plural = "URL Aliases"

    def __unicode__(self):
        return u'%s' % self.urlname
Exemple #6
0
class Link_Body(cms.Model, models.Model):
    """
	Model for resource links associated with this service displayed in the body content
	"""

    qa_objects = cms.QAManager()
    objects = cms.Manager()
    all_objects = models.Manager()

    for_update = models.PositiveSmallIntegerField(default=2, editable=False)
    active = models.CharField(
        max_length=1,
        default=u'1',
        choices=cms.Model.ACTIVE,
        help_text=
        "Select Inactive to remove this link from display and search on the site."
    )
    resource = models.ForeignKey(site.Resource,
                                 related_name='service_resource_body')
    service = models.ForeignKey(Service)
    position = models.PositiveSmallIntegerField(max_length=2)

    class Meta:
        ordering = ['position']
        verbose_name = "Link for content well display"
        verbose_name_plural = "Links for content well display"

    def __unicode__(self):
        return u'%s (%s)' % (self.service, self.resource)
Exemple #7
0
class SundayHours(cms.Model, models.Model):
    """
	Model for additional Sunday hours for locations
	"""

    qa_objects = cms.QAManager()
    objects = cms.Manager()
    all_objects = models.Manager()

    for_update = models.PositiveSmallIntegerField(default=2, editable=False)
    active = models.CharField(
        max_length=1,
        default=u'1',
        choices=cms.Model.ACTIVE,
        help_text=
        "Select Inactive to remove these hours from display on the site.")
    location = models.ForeignKey(Location)
    service = models.ForeignKey('services.Service',
                                related_name='location_sunday_hours')
    position = models.PositiveSmallIntegerField(
        default=1,
        help_text=
        "Enter a number to set the order for this location on display pages. Smaller numbers appear first."
    )
    hours = models.CharField(max_length=150,
                             blank=True,
                             help_text="Service hours eg 7:00 PM - 11:00 PM.")

    class Meta:
        verbose_name_plural = u'Sunday hours'

    def __unicode__(self):
        return u"%d: %s" % (self.pk, self.hours)
Exemple #8
0
class TestModel(cms.Model, Model, models.Model):
    """
	This model tests the content management system and the search system together.
	
	>>> from smgsite.search.models import TestModel
	>>> from smgsite.cms.models import Change
	>>> from smgsite.search import interface
	>>> x = TestModel(testa=5, testb='teststring')
	>>> x.save(preview=False)
	>>> (count, results) = interface.search('prefix', 'TestModel', 'alpha', 'tes', '')
	SEARCH
	prefix
	TestModel
	alpha
	tes
    <BLANKLINE>
    <BLANKLINE>
	['0']
	>>> x.for_update = 0
	>>> x.save(preview=False)
	>>> (count, results) = interface.search('prefix', 'TestModel', 'alpha', 'tes', '')
	SEARCH
	prefix
	TestModel
	alpha
	tes
    <BLANKLINE>
    <BLANKLINE>
	['1', 'TestModel:1:none:teststring']
	>>> x.delete(preview=False)
	>>> (count, results) = interface.search('prefix', 'TestModel', 'alpha', 'tes', '')
	SEARCH
	prefix
	TestModel
	alpha
	tes
    <BLANKLINE>
    <BLANKLINE>
	['0']
	"""

    qa_objects = cms.QAManager()
    objects = cms.Manager()
    all_objects = models.Manager()

    for_update = models.PositiveSmallIntegerField(default=2, editable=False)
    active = models.BooleanField(default=True)
    testa = models.IntegerField()
    testb = models.CharField(max_length=25)

    def search_index(self):
        # Return a (key, url, order, display, name, body) tuple with text for indexing
        return (self.pk, 'none', self.testb, self.testb, self.testb,
                self.testb)
Exemple #9
0
class Image(cms.Model, models.Model):
    """
	Model for an image library.
		
	"""

    qa_objects = cms.QAManager()
    objects = cms.Manager()
    all_objects = models.Manager()

    for_update = models.PositiveSmallIntegerField(default=2, editable=False)
    active = models.CharField(max_length=1,
                              default=u'1',
                              choices=cms.Model.ACTIVE,
                              editable=False)
    name = models.CharField(max_length=50,
                            help_text="Enter a name for this image.")
    category = models.ForeignKey(MediaCategory,
                                 help_text="Select a category for this image.")
    description = models.CharField(
        max_length=200,
        blank=True,
        help_text="Enter an optional description for this image.")
    alt = models.CharField(
        max_length=75,
        help_text=
        "Enter an alt tag value for this image. The text should state the function of the image, such as: 'Welcome to SMG' - 'Greetings from Our Staff' - 'Click to Submit'."
    )
    image = models.ImageField(
        width_field='',
        height_field='',
        upload_to='db/image-library',
        help_text="Image to upload to the image library.")
    thumbnail = models.ImageField(
        blank=True,
        width_field='',
        height_field='',
        upload_to='db/image-library',
        help_text=
        "Optional thumbnail of image. Normally this is created from the image and scaled to be no larger than %sx%s"
        % (THUMBNAIL_MAX_WIDTH, THUMBNAIL_MAX_HEIGHT))

    def __unicode__(self):
        return u'%s' % (self.name)

    def get_absolute_url(self):
        return self.image.url

    def save(self, preview=True):
        if not self.thumbnail:
            image_make_thumbnail(self, 'image', 'thumbnail',
                                 'db/image-library', THUMBNAIL_MAX_WIDTH,
                                 THUMBNAIL_MAX_HEIGHT)
        super(Image, self).save(preview)
Exemple #10
0
class EventBanner(cms.Model, models.Model):
    """
	Model for holding Event Banner images

	Height and width fields are prepopulated with our standard,
	but not enforced by the model.
	"""

    qa_objects = cms.QAManager()
    objects = cms.Manager()
    all_objects = models.Manager()

    for_update = models.PositiveSmallIntegerField(default=2, editable=False)
    active = models.CharField(
        max_length=1,
        default=u'1',
        choices=cms.Model.ACTIVE,
        help_text=
        "Only one Event Banner can be active. If you set this Event Banner to be active, it will deactivate any other event currently set to active."
    )
    name = models.CharField(
        max_length=50, help_text="Please enter a name for this Event Banner.")
    image = models.ImageField(width_field='',
                              height_field='',
                              upload_to='db/event_banners/%Y/%m/%d')
    date_added = models.DateField(auto_now_add=True)
    link = models.ForeignKey(
        Event,
        blank=True,
        null=True,
        help_text="Select the event that this banner links to.")

    def __unicode__(self):
        return self.name

    class Meta:
        verbose_name = "Event Banner"
        verbose_name_plural = "Event Banners"

    def save(self, preview=True, recurse=False):
        if self.active == u'1' and not preview and not recurse:
            for e in EventBanner.objects.all():
                e.active = u'0'
                e.save(preview=False, recurse=True)
            self.active = u'1'
        super(EventBanner, self).save(preview=preview)

    def get_url(self):
        try:
            return self.link.get_absolute_url()
        except Event.DoesNotExist:
            return '/events/'
Exemple #11
0
class Resource(cms.Model, models.Model):
    """
	Model for on-site and off-site resource links.
		
	"""

    qa_objects = cms.QAManager()
    objects = cms.Manager()
    all_objects = models.Manager()

    for_update = models.PositiveSmallIntegerField(default=2, editable=False)
    active = models.CharField(
        max_length=1,
        default=u'1',
        choices=cms.Model.ACTIVE,
        help_text=
        "Select Inactive to remove this article from display and search on the site."
    )
    name = models.CharField(
        max_length=50,
        unique=True,
        help_text="Enter a display name for this resource.")
    description = models.CharField(
        max_length=200,
        blank=True,
        help_text="Enter an optional description for this resource.")
    remote = models.BooleanField(
        editable=False,
        default=False,
        help_text="Check this box if the URL below is outsite the SMG site.")
    url = models.CharField(
        max_length=200,
        unique=True,
        help_text=
        "Enter a URL for this resource (e.g. '/service/cardiology/' or 'http://www.webmd.com/')."
    )

    class Meta:
        ordering = ['name']

    def __unicode__(self):
        return u'%s - %s' % (self.name, self.url)

    def save(self, preview=True):
        self.remote = False
        if host_re.match(self.url):
            self.url = 'http://%s/' % self.url
        elif site_re.match(self.url):
            self.url = 'http://%s' % self.url
        if self.url.startswith('http://'):
            self.remote = True
        super(Resource, self).save(preview)
Exemple #12
0
class VideoTemplate(cms.Model, models.Model):
    """
	Model for magnify.net video template code
	"""

    qa_objects = cms.QAManager()
    objects = cms.Manager()
    all_objects = models.Manager()

    # Each place can have a maximum number of videos
    # which are radomly rotated.
    PLACES = (('H', 'Homepage'), )
    LIMITS = (('H', 1), )

    for_update = models.PositiveSmallIntegerField(default=2, editable=False)
    active = models.CharField(max_length=1,
                              default=u'1',
                              choices=cms.Model.ACTIVE,
                              editable=False)
    location = models.CharField(
        max_length=1,
        choices=PLACES,
        help_text="Select the location for this video.")
    template = models.TextField(
        help_text="Paste the video template generated at magnify.net here.")
    description = models.CharField(verbose_name="Title",
                                   max_length=100,
                                   blank=True,
                                   help_text="Enter a title.")
    summary = models.TextField(blank=True,
                               help_text="Enter a summary paragraph")

    class Meta:
        verbose_name = "Video Template"
        verbose_name_plural = "Video Templates"

    def location_count(self):
        count = [val for key, val in self.LIMITS if key == self.location][0]
        return count

    def __unicode__(self):
        return u'Video template for %s' % (self.get_location_display())

    def save(self, preview=True):
        from django import forms
        current = VideoTemplate.all_objects.filter(location=self.location)
        if len(current) >= self.location_count() and self not in current:
            raise forms.ValidationError(
                'A limit of %d is set for templates for the location %s. Please remove one or more existing templates before attempting to add a new one.'
                % (self.location_count(), self.get_location_display()))
        super(VideoTemplate, self).save(preview=preview)
Exemple #13
0
class Location(cms.Model, models.Model):
    """
	Model for Service locations
	"""

    qa_objects = cms.QAManager()
    objects = cms.Manager()
    all_objects = models.Manager()

    for_update = models.PositiveSmallIntegerField(default=2, editable=False)
    active = models.CharField(
        max_length=1,
        default=u'1',
        choices=cms.Model.ACTIVE,
        help_text=
        "Select Inactive to remove this item from display and search on the site."
    )
    service = models.ForeignKey(Service)
    location = models.ForeignKey(site.Location,
                                 related_name="services_location")
    position = models.PositiveSmallIntegerField(
        default=10,
        help_text=
        "Enter a number to set the order for this location on display pages. Smaller numbers appear first."
    )
    extra1 = models.CharField(
        "First extra info",
        max_length=300,
        blank=True,
        help_text=
        "First extra location information, displayed with the address, e.g. South Building."
    )
    extra2 = models.CharField(
        "Second extra info",
        max_length=300,
        blank=True,
        help_text=
        "Second extra location information, displayed with the address, e.g. Suite 200."
    )
    extra3 = models.CharField(
        "Third extra info",
        max_length=300,
        blank=True,
        help_text=
        "Third extra location information, displayed after the address, e.g. Use rear entrance and left elevator bank."
    )

    def __unicode__(self):
        return u"%d: %s -- %s -- %s" % (self.pk, self.extra1, self.extra2,
                                        self.extra3)
Exemple #14
0
class TrendingTopic(cms.Model, models.Model):

    qa_objects = cms.QAManager()
    objects = cms.Manager()
    all_objects = models.Manager()

    for_update = models.PositiveSmallIntegerField(default=2, editable=False)
    active = models.CharField(
        max_length=1,
        default=u'1',
        choices=cms.Model.ACTIVE,
        help_text=
        "Select Inactive to remove this media result from display and search on the site."
    )
    headline = models.CharField(
        max_length=200, help_text="Enter the headline of this trending topic.")
    content = models.TextField(
        help_text="Enter the content of this trending topic.")
    experts = models.ManyToManyField(
        Doctor,
        blank=True,
        help_text="Select the SMG professionals who are experts for this topic."
    )
    image = models.ImageField(
        blank=True,
        null=True,
        width_field='',
        height_field='',
        upload_to='db/trending-images',
        help_text="Upload an image for this trending topic.")
    sort_order = models.PositiveSmallIntegerField(
        default=None,
        null=True,
        help_text=
        "Select the sort order position for this trending topic. Set to 0 to remove from ordering."
    )

    class Meta:
        ordering = ['-sort_order']
        verbose_name = "SMG Trending Topics"
        verbose_name_plural = "SMG Trending Topics"

    def __unicode__(self):
        return u'%s' % (self.headline)

    def save(self, preview=True, post=True):
        if self.sort_order == 0:
            self.sort_order = None
        super(TrendingTopic, self).save(preview=preview, post=post)
Exemple #15
0
class Degree(cms.Model, models.Model):
    """
	Model for Doctor degrees
	
	Examples include:
	BS: Fairleigh Dickinson University, New Jersey; 1990
	DO: New York College of Osteopathic Medicine, New York
	DPM: Cum Laude, New York College of Podiatric Medicine, New York, NY. June 2004
	
	Has a one-to-many relationship to doctors:
	each doctor can have zero or more degrees.
	"""

    qa_objects = cms.QAManager()
    objects = cms.Manager()
    all_objects = models.Manager()
    qa = False  # Secret QA flag

    parent = 'doctor'

    for_update = models.PositiveSmallIntegerField(default=2, editable=False)
    active = models.CharField(
        max_length=1,
        default=u'1',
        choices=cms.Model.ACTIVE,
        help_text=
        "Select Inactive to remove this item from display and search on the site."
    )
    doctor = models.ForeignKey(Doctor)
    letters = models.ForeignKey(Degree_letters)
    description = models.CharField(
        max_length=300,
        help_text=
        "Enter description (e.g. 'University of Pennsylvania, Pennsylvania; 1973')."
    )

    def __unicode__(self):
        return u"%s %s" % (self.letters, self.description)

    class Meta:
        pass
Exemple #16
0
class Specialty(cms.Model, search.Model, models.Model):
    """
	Model for doctor specialties
	"""

    qa_objects = cms.QAManager()
    objects = cms.Manager()
    all_objects = models.Manager()
    item_url = 'specialty'
    search_order = 3
    search_limit = 10

    for_update = models.PositiveSmallIntegerField(default=2, editable=False)
    active = models.CharField(
        max_length=1,
        default=u'1',
        choices=cms.Model.ACTIVE,
        help_text=
        "Select Inactive to remove this specialty from display and search on the site."
    )
    specialty = models.CharField(max_length=100,
                                 unique=True,
                                 help_text="Enter the name of the specialty.")

    class Meta:
        ordering = ['specialty']
        verbose_name_plural = "Specialties"

    def __unicode__(self):
        return u'%s' % self.specialty

    def get_absolute_url(self):
        return "/doctor-specialty?search-input=%s" % self.specialty

    def search_index(self):
        # Return a (key, url, order, display, name, body) tuple with text for indexing
        return SearchKey(self.pk, self.get_absolute_url(), self.specialty,
                         self.specialty, self.specialty, self.specialty)

    def name(self):
        return self.specialty
Exemple #17
0
class Accreditation(cms.Model, models.Model):
    """
	Model for Doctor accreditations, including residencies, fellowships, and board certifications.
	
	Examples include:
	Residency: Internal Medicine/Primary Care, Columbia Presbyterian Medical Center, New York, NY, 1997-2000
	Board Certification: Licensed Psychologist; Cognitive Therapist, American Academy of Cognitive Therapy
	
	Has a one-to-many relationship to doctors:
	each doctor can have zero or more accreditation entries.
	"""

    qa_objects = cms.QAManager()
    objects = cms.Manager()
    all_objects = models.Manager()
    parent = 'doctor'

    for_update = models.PositiveSmallIntegerField(default=2, editable=False)
    active = models.CharField(
        max_length=1,
        default=u'1',
        choices=cms.Model.ACTIVE,
        help_text=
        "Select Inactive to remove this item from display and search on the site."
    )
    doctor = models.ForeignKey(Doctor)
    name = models.ForeignKey(Accreditation_name)
    description = models.CharField(
        max_length=300,
        help_text=
        "Enter description (e.g. 'Licensed Psychologist; Cognitive Therapist, American Academy of Cognitive Therapy')."
    )

    class Meta:
        pass

    def __unicode__(self):
        return u"%s %s" % (self.name, self.description)
Exemple #18
0
class HomepageImage(cms.Model, models.Model):
    """
	Model for changing specific images on the homepage
	"""

    qa_objects = cms.QAManager()
    objects = cms.Manager()
    all_objects = models.Manager()

    PLACES = (
        ('N', 'Our News'),
        ('H', 'Health'),
        ('E', 'Events'),
    )

    for_update = models.PositiveSmallIntegerField(default=2, editable=False)
    active = models.CharField(max_length=1,
                              default=u'1',
                              choices=cms.Model.ACTIVE,
                              editable=False)
    location = models.CharField(
        max_length=1,
        unique=True,
        choices=PLACES,
        help_text="Select the location for this homepage image.")
    image = models.ForeignKey(
        Image, help_text="Select the image to appear in the selecte location.")
    link = models.URLField(blank=True,
                           help_text="Enter an optional link for this image.")

    class Meta:
        verbose_name = "Homepage Image"
        verbose_name_plural = "Homepage Images"

    def __unicode__(self):
        return u'Homepage image for %s' % (self.get_location_display())
Exemple #19
0
class ServiceGroup(cms.Model, models.Model):
    """
	Model for Service groups
	"""
    qa_objects = cms.QAManager()
    objects = cms.Manager()
    all_objects = models.Manager()

    for_update = models.PositiveSmallIntegerField(default=2, editable=False)

    active = models.CharField(
        max_length=1,
        default=u'1',
        choices=cms.Model.ACTIVE,
        help_text=
        "Select Inactive to remove this service from display and search on the site."
    )
    name = models.CharField(max_length=100)
    description = models.TextField()
    meta_description = models.TextField(
        blank=True, help_text="Enter an optional meta description for SEO.")
    seo_keywords = models.TextField(
        blank=True,
        help_text=
        "Enter optional keywords for SEO. These are not used for site search.")
    urlname = models.CharField(
        max_length=50,
        unique=True,
        help_text="Enter identifier for URL (e.g. enter 'family_health').")
    large_image = models.ImageField(
        upload_to='db/images/service_group',
        help_text="Add a large image for this group.")
    small_image = models.ImageField(
        upload_to='db/images/service_group',
        help_text="Add a small image for this group.")
    marketing_banner = models.ForeignKey(
        MarketingBanner,
        related_name="service_group_marketing_banner",
        blank=True,
        null=True,
        help_text=
        "Enter an additional marketing banner to be associated with this page."
    )
    order = models.PositiveIntegerField(default=0)
    services = models.ManyToManyField(Service, through='ServiceGroupDetail')

    def __str__(self):
        return self.name

    class Meta:
        ordering = ['order']

    def get_absolute_url(self):
        return '/service/group/%s/' % self.urlname
        # reverse is too fragile here because we are not using a slugfield with validation
        #return reverse('service-group', kwargs={'urlname':self.urlname})

    def list_services(self):
        services = ServiceGroupDetail.objects.filter(servicegroup=self)
        s = [
            '<a href="%s">%s</a>' %
            (s.service.get_absolute_url(), s.service.name) for s in services
        ]
        return ', '.join(s)
Exemple #20
0
class Featured(cms.Model, models.Model):
    """
	Model for featured "doctor of the week" practitioners
	"""

    qa_objects = cms.QAManager()
    objects = cms.Manager()
    all_objects = models.Manager()

    for_update = models.PositiveSmallIntegerField(default=2, editable=False)
    active = models.CharField(
        max_length=1,
        default=u'1',
        choices=cms.Model.ACTIVE,
        help_text=
        "Select Inactive to remove this item from display and search on the site."
    )
    doctor = models.ForeignKey(Doctor)
    startdate = models.DateField(
        help_text=
        "Enter a requied date for when to start featuring this practitioner. Dates are inclusive, so a date range of 5-10 would start on the 5th and run through and including the 10th."
    )
    enddate = models.DateField(
        help_text=
        "Enter a requied date after which to stop featuring this practitioner."
    )
    blurb = models.TextField(
        help_text="Enter text to display with this featured practitioner.")

    class Meta:
        ordering = ['startdate', 'enddate']
        verbose_name = "Featured Practitioner"
        verbose_name_plural = "Featured Practitioners"

    def __unicode__(self):
        return u'%s' % (self.doctor)

    def startdate_display(self):
        return u'%s' % self.startdate.strftime('%m-%d-%Y')

    def enddate_display(self):
        return u'%s' % self.enddate.strftime('%m-%d-%Y')

    def save(self, preview=True):
        start = self.startdate
        if self.startdate.__class__ == unicode:
            start = datetime(
                *time.strptime(self.startdate, '%Y-%m-%d')[0:5]).date()
        end = self.enddate
        print start.__class__
        if self.enddate.__class__ == unicode:
            end = datetime(
                *time.strptime(self.enddate, '%Y-%m-%d')[0:5]).date()
        print end.__class__
        if start > end:
            raise forms.ValidationError(
                'The date range you selected has a start date after the end date. Please go back and correct the dates.'
            )
        existing = Featured.all_objects.filter(
            Q(startdate__gte=self.startdate, startdate__lte=self.enddate)
            | Q(enddate__gte=self.startdate, enddate__lte=self.enddate)
        ).exclude(pk=self.pk)
        if existing:
            raise forms.ValidationError(
                'The date range you entered conflicts with another pracitioner who is already being fetured during this period. Please adjust the date range or review the dates for the featured practitioner %s.'
                % (existing[0]))
        else:
            super(Featured, self).save(preview)
Exemple #21
0
class Career(cms.Model, models.Model):
    """
	Model for Careers
	
	This is a model for the careers database.
	"""

    qa_objects = cms.QAManager()
    objects = cms.Manager()
    all_objects = models.Manager()
    item_url = 'career'

    SHIFT_TYPE = (
        ('F', 'Full time'),
        ('P', 'Part time'),
        ('D', 'Per Diem'),
    )

    SHIFT_TIME = (
        ('M', 'Morning'),
        ('D', 'Day'),
        ('A', 'Afternoon/Evening'),
        ('E', 'Evening'),
        ('L', 'Late Night'),
        ('W', 'Weekend Day'),
        ('F', 'Flexible'),
    )

    STATUS = (
        ('N', 'New'),
        ('H', 'Hold'),
        ('O', 'Open'),
    )

    BENEFITS = (
        ('N', 'No'),
        ('Y', 'Yes'),
    )

    for_update = models.PositiveSmallIntegerField(default=2, editable=False)
    active = models.CharField(max_length=1,
                              default=u'1',
                              choices=cms.Model.ACTIVE,
                              editable=False)
    job_title = models.CharField(max_length=50,
                                 help_text='Enter a title for this job.')
    position_number = models.CharField(
        max_length=12,
        blank=True,
        help_text='Enter an option position number for this job.')
    department = models.CharField(max_length=50,
                                  help_text='Enter a department name.')
    service = models.CharField(
        max_length=50,
        blank=True,
        help_text="Enter an optional service/specialty for this job.")
    location = models.ForeignKey(
        Location,
        blank=True,
        null=True,
        help_text="Select an optional site location at SMG.")
    other_location = models.TextField(
        blank=True, help_text="If no site location, enter a location here.")
    shift = models.CharField(max_length=50,
                             blank=True,
                             help_text="Enter shift information for this job.")
    shift_type = models.CharField(max_length=1,
                                  choices=SHIFT_TYPE,
                                  default='F')
    shift_time = models.CharField(max_length=1,
                                  choices=SHIFT_TIME,
                                  default='A')
    hours = models.CharField(
        max_length=8,
        blank=True,
        help_text="Enter hours for this job (e.g. 40, or 37.5, or per diem).")
    description = models.TextField(
        help_text="Enter a description for this job.")
    date_posted = models.DateField(
        help_text="Enter a posting date for this job.")
    status = models.CharField(max_length=1, choices=STATUS, default='O')
    date_added = models.DateField(auto_now_add=True)
    benefits = models.CharField(max_length=1, choices=BENEFITS, default='N')
    requirements = models.TextField(
        blank=True, help_text="Enter the requirements for this job.")

    class Meta:
        ordering = ['date_posted', 'job_title']

    def __unicode__(self):
        return self.job_title

    def shift_type_str(self):
        d = dict(self.SHIFT_TYPE)
        return u'%s' % d[self.shift_type]

    def shift_time_str(self):
        d = dict(self.SHIFT_TIME)
        return u'%s' % d[self.shift_time]

    def status_str(self):
        d = dict(self.STATUS)
        return u'%s' % d[self.status]

    def get_absolute_url(self):
        return "/%s/%s/" % (self.item_url, self.pk)
Exemple #22
0
class MediaResult(cms.Model, search.Model, models.Model):

    qa_objects = cms.QAManager()
    objects = cms.Manager()
    all_objects = models.Manager()
    item_url = 'recentcoverage'
    search_order = 8
    search_limit = 10

    for_update = models.PositiveSmallIntegerField(default=2, editable=False)
    active = models.CharField(
        max_length=1,
        default=u'1',
        choices=cms.Model.ACTIVE,
        help_text=
        "Select Inactive to remove this media result from display and search on the site."
    )
    urlname = models.CharField(
        max_length=50,
        unique=True,
        help_text=
        "Enter folder for URL (e.g. enter 'Health-At-SMG' to have this media result load at '/recentcoverage/Health-At-SMG/'). This is normally created for you from the headline."
    )
    aliases = models.ManyToManyField(URLAlias,
                                     blank=True,
                                     null=True,
                                     help_text="URL Aliases")
    keywords = models.CharField(
        max_length=500,
        blank=True,
        help_text="Enter optional Top Match keywords separated by spaces.")
    meta_description = models.TextField(
        blank=True, help_text="Enter an optional meta description for SEO.")
    posting_time = models.DateTimeField(
        help_text=
        "Set the posting time to when this feature will appear live on the site. This date and time will also be used for sort order in lists. This should not be changed after the feature is created."
    )
    display_time = models.DateTimeField(
        help_text=
        "The display time is used for the feature display, and can be changed to reflect updates."
    )
    headline = models.CharField(
        max_length=200, help_text="Enter the headline of this feature.")
    byline = models.CharField(
        max_length=100,
        blank=True,
        help_text="Optionally enter a byline for this Media Result.")
    byline_link = models.CharField(
        max_length=100,
        blank=True,
        help_text=
        "Optionally enter a byline link for this Media Result. This can be relative, like '/services/' or fully qualified, like 'http://www.sumitmedicalgroup.com'. Be sure to test."
    )
    image = models.ImageField(
        blank=True,
        null=True,
        width_field='',
        height_field='',
        upload_to='db/mediaresult-images',
        help_text="Upload an image for this media result.")
    content = models.TextField(help_text="Enter the media result body above.")
    marketing_banner = models.ForeignKey(
        MarketingBanner,
        related_name="mediaresult_marketing_banner",
        blank=True,
        null=True,
        help_text=
        "Enter an additional marketing banner to be associated with this page."
    )
    sort_order = models.PositiveSmallIntegerField(
        default=None,
        null=True,
        help_text=
        "Select the sort order position for this trending topic. Set to 0 to remove from ordering."
    )
    blurb = models.TextField(
        blank=True,
        help_text=
        'Blurb text should be a short summary of the article, it will display on preview lists'
    )

    class Meta:
        ordering = ['-posting_time']
        verbose_name = "SMG Media Result"
        verbose_name_plural = "SMG Media Results"

    def __unicode__(self):
        return u'%s' % (self.headline)

    def get_absolute_url(self):
        return "/%s/%s/" % (self.item_url, self.urlname)

    def display_time_for_display(self):
        return u'%s' % self.display_time.strftime('%m-%d-%Y')

    def relative_age(self):
        return common_relative_age(self)

    @staticmethod
    def is_live(key):
        try:
            posting_time = Feature.all_objects.get(id=key).posting_time
            return posting_time <= datetime.now()
        except:
            return False

    def is_archive(self):
        return self.posting_time < datetime.today() - timedelta(
            days=ARCHIVE_AGE)

    def search_index(self):
        # Return a (key, url, order, display, name, body) tuple with text for indexing
        if self.posting_time.__class__ == unicode:
            posting_time = datetime(
                *time.strptime(self.posting_time, "%Y-%m-%d %H:%M:%S")[0:5])
        else:
            posting_time = self.posting_time
        body = "%s %s" % (self.headline, self.content)
        return SearchKey(self.pk, self.get_absolute_url(),
                         posting_time.isoformat(), self.headline,
                         self.headline, body)

    def keyword_index(self):
        # Return a (key, url, order, display, name, body) tuple with text for indexing
        if self.posting_time.__class__ == unicode:
            posting_time = datetime(
                *time.strptime(self.posting_time, "%Y-%m-%d %H:%M:%S")[0:5])
        else:
            posting_time = self.posting_time
        return SearchKey(self.pk, self.get_absolute_url(),
                         posting_time.isoformat(), self.headline,
                         self.keywords, self.keywords)

    def save(self, preview=True, post=True):
        if self.sort_order == 0:
            self.sort_order = None
        super(MediaResult, self).save(preview=preview, post=post)
Exemple #23
0
class Location(cms.Model, search.Model, models.Model):
    """
	Model for SMG Locationes

	"""

    SHOW = 1
    HIDE = 0
    DISPLAY = (
        (u'1', 'Show in Lists'),
        (u'0', 'Hide from Lists'),
    )

    STATE_CHOICES = (
        ('AL', 'Alabama'),
        ('AK', 'Alaska'),
        ('AS', 'American Samoa'),
        ('AZ', 'Arizona'),
        ('AR', 'Arkansas'),
        ('CA', 'California'),
        ('CO', 'Colorado'),
        ('CT', 'Connecticut'),
        ('DE', 'Delaware'),
        ('DC', 'District of Columbia'),
        ('FM', 'Federated States of Micronesia'),
        ('FL', 'Florida'),
        ('GA', 'Georgia'),
        ('GU', 'Guam'),
        ('HI', 'Hawaii'),
        ('ID', 'Idaho'),
        ('IL', 'Illinois'),
        ('IN', 'Indiana'),
        ('IA', 'Iowa'),
        ('KS', 'Kansas'),
        ('KY', 'Kentucky'),
        ('LA', 'Louisiana'),
        ('ME', 'Maine'),
        ('MH', 'Marshall Islands'),
        ('MD', 'Maryland'),
        ('MA', 'Massachusetts'),
        ('MI', 'Michigan'),
        ('MN', 'Minnesota'),
        ('MS', 'Mississippi'),
        ('MO', 'Missouri'),
        ('MT', 'Montana'),
        ('NE', 'Nebraska'),
        ('NV', 'Nevada'),
        ('NH', 'New Hampshire'),
        ('NJ', 'New Jersey'),
        ('NM', 'New Mexico'),
        ('NY', 'New York'),
        ('NC', 'North Carolina'),
        ('ND', 'North Dakota'),
        ('MP', 'Northern Mariana Islands'),
        ('OH', 'Ohio'),
        ('OK', 'Oklahoma'),
        ('OR', 'Oregon'),
        ('PW', 'Palau'),
        ('PA', 'Pennsylvania'),
        ('PR', 'Puerto Rico'),
        ('RI', 'Rhode Island'),
        ('SC', 'South Carolina'),
        ('SD', 'South Dakota'),
        ('TN', 'Tennessee'),
        ('TX', 'Texas'),
        ('UT', 'Utah'),
        ('VT', 'Vermont'),
        ('VI', 'Virgin Islands'),
        ('VA', 'Virginia'),
        ('WA', 'Washington'),
        ('WV', 'West Virginia'),
        ('WI', 'Wisconsin'),
        ('WY', 'Wyoming'),
    )

    DAY_CHOICES = ((u'1', 'Yes'), (u'0', 'No'))

    qa_objects = cms.QAManager()
    objects = cms.Manager()
    all_objects = models.Manager()
    item_url = 'location'
    search_order = 5
    search_limit = 10

    for_update = models.PositiveSmallIntegerField(default=2, editable=False)
    active = models.CharField(
        max_length=1,
        default=u'1',
        choices=cms.Model.ACTIVE,
        help_text=
        "Select Inactive to remove this location from display and search on the site."
    )
    display = models.CharField(
        max_length=1,
        default=u'1',
        choices=DISPLAY,
        help_text=
        "Select Hide from Lists to prevent this location from displaying on the /location/ page."
    )
    urlname = models.CharField(
        max_length=50,
        unique=True,
        help_text=
        "Enter identifier for URL, e.g. enter 'berkeley_heights' to have this Doctor load at '/location/berkeley_heights/')"
    )
    keywords = models.CharField(
        max_length=500,
        blank=True,
        help_text="Enter optional Top Match keywords separated by spaces.")
    meta_description = models.TextField(
        blank=True, help_text="Enter an optional meta description for SEO.")
    name = models.CharField(
        max_length=100,
        help_text=
        "Enter the administrative name for this location, e.g. Summit Satellite."
    )
    display_name = models.CharField(
        max_length=100,
        blank=True,
        help_text=
        "Enter the web display name for this location, e.g. Overlook Hopsital-MAC Building."
    )
    description = models.CharField(
        max_length=100,
        blank=True,
        help_text=
        "(Optional) Enter a short desciption or other information, e.g. Behavioral Health Only."
    )
    address = models.CharField(
        max_length=100,
        help_text=
        "Enter the street address for this location, e.g. 85 Woodland Road. Do not use this field for any information except a valid postal street address."
    )
    address2 = models.CharField(
        max_length=100,
        blank=True,
        help_text=
        "(Optional) Continue the street address for this location, e.g. Suite 304)."
    )
    city = models.CharField(
        max_length=100,
        help_text="Enter the city name for this location, e.g. Short Hills).")
    state = models.CharField(max_length=2, choices=STATE_CHOICES, default='NJ')
    zipcode = models.CharField(
        max_length=5, help_text="Enter the zip code for this location.")
    phone = models.CharField(
        max_length=19,
        blank=True,
        help_text="Enter a phone number for this location.")
    fax = models.CharField(
        max_length=19,
        blank=True,
        help_text="Enter on optional fax number for this location.")
    original_image = models.ImageField(
        blank=True,
        null=True,
        width_field='',
        height_field='',
        upload_to='db/location-images',
        help_text=
        "Upload an image for this location. This image will automatically be scaled to and %sx%s for display on the site."
        % (IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT))
    image = models.ImageField(
        blank=True,
        null=True,
        editable=False,
        width_field='',
        height_field='',
        upload_to='db/location-images',
    )
    parking_code = models.CharField(
        max_length=5,
        blank=True,
        help_text=
        "Enter an optional parking code for this location, e.g. B or ASC.")
    parking_name = models.CharField(
        max_length=50,
        blank=True,
        help_text=
        "Enter an optional name for the parking area, e.g. Bensley Pavilion.")
    glatitude = models.CharField(max_length=25,
                                 blank=False,
                                 help_text="Enter latitude for google maps.")
    glongitude = models.CharField(max_length=25,
                                  blank=False,
                                  help_text="Enter longitude for google maps.")
    order = models.PositiveIntegerField(
        help_text=
        "Enter a number for the order in which this location should be displayed in lists."
    )
    info = models.TextField(
        blank=True,
        help_text="Enter an optional description for this location.")
    starttime = models.TimeField(
        blank=True,
        null=True,
        help_text=
        "Enter an optional 24-hour time for this location's standard opening time."
    )
    endtime = models.TimeField(
        blank=True,
        null=True,
        help_text=
        "Enter an optional 24-hour time for this location's standard closing time."
    )
    monday = models.CharField(
        max_length=1,
        default=u'1',
        choices=DAY_CHOICES,
        help_text="Select if a standard weekday opening.")
    tuesday = models.CharField(
        max_length=1,
        default=u'1',
        choices=DAY_CHOICES,
        help_text="Select if a standard weekday opening.")
    wednesday = models.CharField(
        max_length=1,
        default=u'1',
        choices=DAY_CHOICES,
        help_text="Select if a standard weekday opening.")
    thursday = models.CharField(
        max_length=1,
        default=u'1',
        choices=DAY_CHOICES,
        help_text="Select if a standard weekday opening.")
    friday = models.CharField(
        max_length=1,
        default=u'1',
        choices=DAY_CHOICES,
        help_text="Select if a standard weekday opening.")
    hours_comments = models.TextField(
        blank=True,
        help_text="Enter optional comments for hours at this location.")

    class Meta:
        ordering = ['order', 'name']

    def __unicode__(self):
        if self.parking_name:
            return u'%s - %s' % (self.name, self.parking_name)
        else:
            return u'%s' % (self.name)

    def get_absolute_url(self):
        return "/%s/%s/" % (self.item_url, self.urlname)

    def options(self):
        weekday = self.weekdayhours_set.all()
        saturday = self.saturdayhours_set.all()
        sunday = self.sundayhours_set.all()
        if weekday or saturday or sunday:
            return True
        return False

    def save(self, preview=True):
        # We use thumbnail in templates can preserve original image here I think.
        #if self.original_image:
        #image_make_thumbnail(self, 'original_image', 'image', 'db/location-images', IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT)
        super(Location, self).save(preview)
        cache.delete('finder-location-berkeley')
        cache.delete('finder-location-subberkeley')
        cache.delete('finder-location-notberkeley')
        snbkey = self.city.replace(' ', '_')
        cache.delete('finder-location-subnotberkeley-%s' % snbkey)
        cache.delete('finder-locations')

    def search_index(self):
        # Return a (key, url, order, display, name, body) tuple with text for indexing
        body = u'%s %s %s %s %s %s %s %s %s' % (
            self.name, self.address, self.address2, self.city, self.state,
            self.zipcode, self.phone, self.fax, self.parking_name)
        return SearchKey(self.pk, self.get_absolute_url(), self.order,
                         self.name, self.name, body)

    def keyword_index(self):
        # Return a (key, url, order, display, name, body) tuple with text for keyword indexing
        return SearchKey(self.pk, self.get_absolute_url(), self.order,
                         self.name, self.keywords, self.keywords)

    @property
    def get_display_name(self):
        # noticed that sometimes there is no display name so will return the name instead
        if self.display_name:
            return self.display_name
        else:
            return self.name

    @property
    def display_address(self):
        # address format probably needs to be refactored
        address_list = filter(
            None, (self.display_name, self.address, self.address2, self.city,
                   '%s %s' % (self.state, self.zipcode)))
        print ', '.join(address_list)
        return ', '.join(address_list)

    @property
    def display_image(self):
        if self.original_image:
            return self.original_image
        else:
            return MissingImage(name='db/image-library/location_default.jpg')
Exemple #24
0
class Service(cms.Model, search.Model, models.Model):
    """
	Model for Services and Specialties
	
	This is a list of all the specialties and services at SMG.
	"""

    qa_objects = cms.QAManager()
    objects = cms.Manager()
    all_objects = models.Manager()
    item_url = 'service'
    template_path = 'services'
    search_order = 2
    search_limit = 10

    for_update = models.PositiveSmallIntegerField(default=2, editable=False)
    active = models.CharField(
        max_length=1,
        default=u'1',
        choices=cms.Model.ACTIVE,
        help_text=
        "Select Inactive to remove this service from display and search on the site."
    )
    urlname = models.CharField(
        max_length=50,
        unique=True,
        help_text=
        "Enter identifier for URL (e.g. enter 'cardiology' to have this Service load at '/service/cardiology/')."
    )
    template = models.ForeignKey(
        Template,
        blank=True,
        null=True,
        help_text=
        "Select the template to be used to render this service for display.")
    aliases = models.ManyToManyField(URLAlias,
                                     blank=True,
                                     null=True,
                                     help_text="URL Aliases")
    keywords = models.CharField(
        max_length=500,
        blank=True,
        help_text="Enter optional Top Match keywords separated by spaces.")
    meta_description = models.TextField(
        blank=True, help_text="Enter an optional meta description for SEO.")
    seo_keywords = models.TextField(
        blank=True,
        help_text=
        "Enter optional keywords for SEO. These are not used for site search.")
    name = models.CharField(
        max_length=100,
        unique=True,
        help_text="Enter the full name of this service (e.g. Cardiology).")
    practitioner_name = models.CharField(
        max_length=100,
        blank=True,
        help_text=
        "Enter the name of a practitoner of this service (e.g. Cardiologist).")
    practitioner_group = models.CharField(
        max_length=100,
        blank=True,
        help_text=
        "Enter the group name for practitioners of this service (e.g. Our Cardiologists)."
    )
    description_short = models.CharField(
        max_length=200,
        blank=True,
        help_text=
        "A short description for this service (e.g. Heart and Blood Vessel Disorders)."
    )
    phone = models.CharField(max_length=19,
                             blank=True,
                             help_text="Enter phone number.")
    #location = models.ForeignKey(site.Location, blank=True, null=True, help_text="Select a location for this service.")
    related_services = models.ManyToManyField(
        'Service',
        blank=True,
        null=True,
        symmetrical=False,
        help_text="Select optional related services to display in the nav.")
    content = models.TextField(blank=True)
    offerings = models.TextField(blank=True)
    learn_more = models.TextField(blank=True)
    patient_tools = models.TextField(blank=True)
    #location = models.TextField(blank=True)
    #original_image = models.ImageField(blank=True, null=True, width_field='', height_field='', upload_to='db/service-images', help_text="Upload an image for this service. This image will automatically be scaled to no greater than %sx%s for display on the site." % (IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT))
    #image = models.ImageField(blank=True, null=True, width_field='', height_field='', upload_to='db/service-images')
    date_added = models.DateField(auto_now_add=True)
    blog = models.ForeignKey(Blog, blank=True, null=True)
    marketing_banner = models.ForeignKey(
        MarketingBanner,
        related_name="services_marketing_banner",
        blank=True,
        null=True,
        help_text=
        "Enter an additional marketing banner to be associated with this page."
    )
    large_image = models.ImageField(
        blank=True,
        upload_to='db/images/service',
        help_text="Add a large image for this service.")
    small_image = models.ImageField(
        blank=True,
        upload_to='db/images/service',
        help_text="Add a small image for this service.")

    class Meta:
        ordering = ['name']

    def __unicode__(self):
        return self.name

    def save(self, preview=True):
        super(Service, self).save(preview)
        cache.delete('finder-services-list')
        cache.delete('finder-specialty')

    def get_nav_links(self):
        if hasattr(self, "qa") and self.qa:
            links = self.link_nav_set.select_related().order_by(
                'services_link_nav.position')
        else:
            links = self.link_nav_set.model.objects.filter(
                service=self).select_related().order_by(
                    'services_link_nav.position')
        return [x.resource for x in links]

    def get_body_links(self):
        if hasattr(self, "qa") and self.qa:
            links = self.link_body_set.select_related().order_by(
                'services_link_body.position')
        else:
            links = self.link_body_set.model.objects.filter(
                service=self).select_related().order_by(
                    'services_link_body.position')
        return [x.resource for x in links]

    """
	The distinction between local and remote nav links has been removed from the presentation layer.
	def get_local_nav_links(self):
		if hasattr(self, "qa") and self.qa:
			links = self.link_nav_set.select_related().filter(resource__remote=False).order_by('services_link_nav.position')
		else:
			links = self.link_nav_set.model.objects.filter(service=self).select_related().filter(resource__remote=False).order_by('services_link_nav.position')
		return [x.resource for x in links]
		
	def get_remote_nav_links(self):
		if hasattr(self, "qa") and self.qa:
			links = self.link_nav_set.select_related().filter(resource__remote=True).order_by('services_link_nav.position')
		else:
			links = self.link_nav_set.model.objects.filter(service=self).select_related().filter(resource__remote=True).order_by('services_link_nav.position')
		return [x.resource for x in links]
	"""

    def get_absolute_url(self):
        return "/%s/%s/" % (self.item_url, self.urlname)

    def blog_list(self):
        return self.blog.blogentry_set.all()[:5]

    def cms_template_id_display(self, template_id):
        try:
            name = Template.objects.get(pk=template_id).name
        except Template.DoesNotExist:
            name = 'None'
        return name

    def letter_key(self):
        return self.name[0]

    def pkstr(self):
        return u'%s' % self.pk

    def location_plural(self):
        return len(self.location_set.filter(active='1', for_update__lte=1)) > 1

    def locations(self):
        return self.location_set.filter(active='1',
                                        for_update__lte=1).order_by('position')

    def search_index(self):
        # Return a (key, url, order, display, name, body) tuple with text for indexing
        body = "%s %s %s %s" % (self.name, self.practitioner_name,
                                self.practitioner_group, self.content)
        return SearchKey(self.pk, self.get_absolute_url(), self.name,
                         self.name, self.name, body)

    def keyword_index(self):
        # Return a (key, url, order, display, name, body) tuple with text for keyword indexing
        return SearchKey(self.pk, self.get_absolute_url(), self.name,
                         self.name, self.keywords, self.keywords)

    @property
    def display_large_image(self):
        if self.large_image:
            return self.large_image
        else:
            return site.MissingImage(
                name='db/image-library/service_default.jpg')

    @property
    def display_small_image(self):
        if self.small_image:
            return self.small_image
        else:
            return site.MissingImage(
                name='db/image-library/service_default.jpg')
Exemple #25
0
class Eventtime(cms.Model, models.Model):
    """
	Model for Event times
	"""

    qa_objects = cms.QAManager()
    objects = cms.Manager()
    all_objects = models.Manager()

    CANCELLED = (('A', 'Active'), ('C', 'Cancelled'))

    for_update = models.PositiveSmallIntegerField(default=2, editable=False)
    active = models.CharField(
        max_length=1,
        default=u'1',
        choices=cms.Model.ACTIVE,
        help_text=
        "Select Inactive to remove this item from display and search on the site."
    )
    event = models.ForeignKey(Event)
    startdate = models.DateField(
        help_text="Enter a requied date for when this event starts.")
    starttime = models.TimeField(
        blank=True,
        null=True,
        help_text="Enter an option 24-hour time for when this event starts.")
    enddate = models.DateField(
        help_text="Enter a requied date for when this event ends.")
    endtime = models.TimeField(
        blank=True,
        null=True,
        help_text="Enter an option 24-hour time for when this event ends.")
    cancelled = models.CharField(max_length=1,
                                 choices=CANCELLED,
                                 default='A',
                                 help_text="Cancel this event?")

    def __unicode__(self):
        return u"%s: %s -- %s to %s -- %s" % (self.event.title, self.startdate,
                                              self.starttime, self.enddate,
                                              self.endtime)

    def timelong(self):
        if self.startdate == self.enddate:
            if not self.starttime and not self.endtime:
                val = u'%s' % (self.startdate.strftime('%A, %B %d, %Y'))
            elif not self.starttime:
                val = u'%s, - %s' % (self.startdate.strftime('%A, %B %d, %Y'),
                                     self.endtime.strftime('%I:%M %p'))
            elif not self.endtime:
                val = u'%s, %s' % (self.startdate.strftime('%A, %B %d, %Y'),
                                   self.starttime.strftime('%I:%M %p'))
            else:
                val = u'%s, %s - %s' % (self.startdate.strftime(
                    '%A, %B %d, %Y'), self.starttime.strftime('%I:%M %p'),
                                        self.endtime.strftime('%I:%M %p'))
        else:
            val = u'%s - %s' % (self.startdate.strftime('%A, %B %d, %Y'),
                                self.enddate.strftime('%A, %B %d, %Y'))
        return zero_re.sub(' \\1', val)

    def timeshort(self):
        if self.startdate == self.enddate:
            if not self.starttime:
                val = u'%s' % (self.startdate.strftime('%a., %b. %d'))
            else:
                val = u'%s, %s' % (self.startdate.strftime('%a., %b. %d'),
                                   self.starttime.strftime('%I:%M %p'))
        else:
            val = u'%s - %s' % (self.startdate.strftime('%a., %b. %d'),
                                self.enddate.strftime('%a., %b. %d'))
        return zero_re.sub(' \\1', val)

    def expired(self):
        if self.enddate < date.today():
            return True
        return False
Exemple #26
0
class Page(cms.Model, search.Model, models.Model):
    """
	Model for CMS controlled custom pages on the site.
	"""
    qa_objects = cms.QAManager()
    objects = cms.Manager()
    all_objects = models.Manager()
    search_order = 8
    search_limit = 10

    for_update = models.PositiveSmallIntegerField(default=2, editable=False)
    active = models.CharField(
        max_length=1,
        default=u'1',
        choices=cms.Model.ACTIVE,
        help_text=
        "Select Inactive to remove this page from display and search on the site."
    )
    directory = models.ForeignKey(Directory, blank=True, null=True)
    urlname = models.CharField(
        max_length=50,
        blank=True,
        help_text=
        "Enter end of URL (e.g. enter 'aboutus' to have this Service load at '/aboutus/'). This Urlname is appended to the Directory above to create the complete path. It is not necessary to enter / characters."
    )
    keywords = models.CharField(
        max_length=500,
        blank=True,
        help_text="Enter optional Top Match keywords separated by spaces.")
    meta_description = models.TextField(
        blank=True, help_text="Enter an optional meta description for SEO.")
    title = models.CharField(max_length=100,
                             help_text="Enter the title of this page.")
    content = models.TextField(blank=True)
    marketing_banner = models.ForeignKey(
        MarketingBanner,
        related_name="pages_marketing_banner",
        blank=True,
        null=True,
        help_text=
        "Enter an additional marketing banner to be associated with this page."
    )

    url = models.CharField(
        'URL',
        blank=True,
        max_length=100,
        help_text="Enter URL path for this page. Example: /help/faq/")
    template_name = models.CharField(
        'Template',
        max_length=70,
        blank=True,
        help_text=
        "Select a template. If this isn't provided, the system will use 'default.html'."
    )

    class Meta:
        verbose_name = 'Summit Medical Group Pages'
        verbose_name_plural = 'Summit Medical Group Pages'

    def __unicode__(self):
        return self.title

    def get_absolute_url(self):
        if self.urlname:
            return "/%s/%s/" % (self.directory, self.urlname)
        else:
            return iri_to_uri(get_script_prefix().rstrip('/') + self.url)

    def cms_directory_id_display(self, directory_id):
        if self.directory:
            try:
                return Directory.objects.get(pk=directory_id).directory
            except:
                return '(none)'
        else:
            return '(none)'

    def search_index(self):
        # Return a (key, url, order, display, name, body) tuple with text for indexing
        body = "%s %s" % (self.title, self.content)
        return SearchKey(self.pk, self.get_absolute_url(), self.title,
                         self.title, self.title, body)

    def keyword_index(self):
        # Return a (key, url, order, display, name, body) tuple with text for keyword indexing
        return SearchKey(self.pk, self.get_absolute_url(), self.title,
                         self.title, self.keywords, self.keywords)
Exemple #27
0
class Doctor(cms.Model, search.Model, models.Model):
    """
	Model for Doctor information
	
	# ***Unit testing to ensure uniqueness constraints are obeyed***
	>>> from smgsite.doctors.models import Doctor
	>>> doctor = Doctor.objects.create(first_name="A", last_name="Test", urlname="test1", email="test1", phone='11')
	>>> doctor2 = Doctor.objects.create(first_name="A", last_name="Test2", urlname="test2", email="test2", phone='11')
	>>> doctor3 = Doctor.objects.create(first_name="A", last_name="Test3", urlname="test1", email="test3", phone='11')
	Traceback (most recent call last):
		...
    IntegrityError: (1062, "Duplicate entry 'test1' for key 2")
	>>> doctor4 = Doctor.objects.create(first_name="A", last_name="Test4", urlname="test4", email="test1", phone='11')
	Traceback (most recent call last):
		...
    IntegrityError: (1062, "Duplicate entry 'test1' for key 3")
	>>> doctor4.delete()
	Traceback (most recent call last):
		...
	NameError: name 'doctor4' is not defined
	>>> doctor3.delete()
	Traceback (most recent call last):
		...
	NameError: name 'doctor3' is not defined
	>>> doctor2.delete()
	>>> doctor.delete()
	
	# ***Unit testing for fields and search -- ensures created fields are returned for the search index***
	>>> from smgsite.doctors.models import Doctor
	>>> doctor = Doctor.objects.create(first_name="A", last_name="Test", urlname="test", email="test", phone='11')
	>>> doctor.services.create(name="Slicing", urlname="slicing")
	<Service: Slicing>
	>>> doctor.services.create(name="Dicing", urlname="dicing")
	<Service: Dicing>
	>>> index = doctor.search_index()
	>>> index
	(3L, '/doctor/test/', 'Test', 'A  Test ', 'A Test', 'A  Test  Dicing Slicing ')
	
	"""

    qa_objects = cms.QAManager()
    objects = cms.Manager()
    all_objects = models.Manager()
    item_url = 'doctor'
    search_order = 1
    search_limit = 10

    STATUS = (
        ('D', 'Doctor'),
        ('S', 'Staff'),
    )

    ACCEPTING = (
        ('A', 'Accepting'),
        ('P', 'No PCP'),
        ('N', 'Not Accepting'),
    )

    GENDER = (
        ('F', 'Female'),
        ('M', 'Male'),
    )

    PARTICIPATE = (
        ('P', 'Participates in athenahealth'),
        ('D', 'Does not participate'),
        ('M', 'Participates in Paramount'),
    )

    for_update = models.PositiveSmallIntegerField(default=2, editable=False)
    active = models.CharField(
        max_length=1,
        default=u'1',
        choices=cms.Model.ACTIVE,
        help_text=
        "Select Inactive to remove this person from display and search on the site."
    )
    urlname = models.CharField(
        max_length=50,
        unique=True,
        help_text=
        "Enter identifier for URL (e.g. enter 'jsmith' to have this Doctor load at '/doctor/jsmith/')"
    )
    keywords = models.CharField(
        max_length=500,
        blank=True,
        help_text="Enter optional Top Match keywords separated by spaces.")
    meta_description = models.TextField(
        blank=True, help_text="Enter an optional meta description for SEO.")
    seo_keywords = models.TextField(
        blank=True,
        help_text=
        "Enter optional keywords for SEO. These are not used for site search.")
    prefix = models.CharField(
        max_length=5,
        blank=True,
        help_text="Enter name prefix (e.g. Dr.) or leave blank.")
    first_name = models.CharField(max_length=25, help_text="Enter first name.")
    middle_name = models.CharField(max_length=25,
                                   blank=True,
                                   help_text="Enter middle name or initial.")
    last_name = models.CharField(max_length=25, help_text="Enter last name.")
    gender = models.CharField(max_length=1, choices=GENDER)
    suffix = models.CharField(max_length=25,
                              blank=True,
                              help_text="Enter suffic (e.g. Jr. or III)")
    letters = models.CharField(
        max_length=50,
        help_text=
        "Enter accreditation letters for name display, without periods (e.g. MD, FACP)."
    )
    email = models.EmailField(
        unique=True,
        help_text=
        "Enter email address, usually first initial last name @smgnj.com (e.g. [email protected])."
    )
    phone = models.CharField(max_length=100, help_text="Enter phone number.")
    phone_note = models.CharField(max_length=500,
                                  blank=True,
                                  help_text="Enter phone notes.")
    #fax = models.CharField(max_length=19, blank=True, help_text="Enter fax number or leave blank.")
    #location = models.ForeignKey(site.Location, blank=True, null=True, help_text="Select a location for this person.")
    #extra_locations = models.ManyToManyField(site.Location, blank=True, related_name='extra_locations', help_text="Select any additional locations for this praticioner.")
    hospitals = models.ManyToManyField(
        Hospital,
        blank=True,
        help_text=
        "Select any number of hospital locations for this practitioner.")
    languages = models.ManyToManyField(
        Language,
        default="English",
        help_text="Select the languages spoken by this practitioner.")
    original_image = models.ImageField(
        blank=True,
        null=True,
        width_field='',
        height_field='',
        upload_to='db/doctor-images',
        help_text=
        "Upload an image for this doctor. This image will automatically be scaled to two versions, %sx%s and %sx%s"
        % (IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT, THUMBNAIL_MAX_WIDTH,
           THUMBNAIL_MAX_HEIGHT))
    image = models.ImageField(blank=True,
                              null=True,
                              width_field='',
                              height_field='',
                              upload_to='db/doctor-images')
    thumbnail = models.ImageField(blank=True,
                                  null=True,
                                  width_field='',
                                  height_field='',
                                  upload_to='db/doctor-images')
    cropped_image = models.ImageField(
        blank=True,
        null=True,
        width_field='',
        height_field='',
        upload_to='db/doctor-images',
        help_text=
        "Upload a cropped image for this doctor. This image will be used for the flyover on the doctors index page."
    )
    date_added = models.DateField(auto_now_add=True)
    title_service = models.ForeignKey(
        Service,
        related_name="title_service",
        null=True,
        help_text=
        "Enter the primary specialty for this person, which will display on the Doctor listing page."
    )
    services = models.ManyToManyField(
        Service,
        related_name="services",
        blank=True,
        null=True,
        help_text=
        "Enter any additional specialties for this person. The primary specialty should not be selected again."
    )
    touch = models.TextField(
        blank=True,
        help_text="Enter optional personal touch content for this doctor.")
    exclude_from_index = models.CharField(
        max_length=1,
        default=u'0',
        choices=cms.Model.EXCLUDE,
        help_text=
        "Select Exclude to remove this person from listing in the main doctors index pages."
    )
    blog = models.ForeignKey(Blog, blank=True, null=True)
    status = models.CharField(
        max_length=1,
        choices=STATUS,
        default='D',
        help_text="Selected if this entry is for a doctor or a staff member.")

    accepting_flag = models.CharField(
        max_length=1,
        default='A',
        choices=ACCEPTING,
        help_text=
        "Select whether this doctor is currently accepting new patients.")
    accepting = models.TextField(
        blank=True,
        help_text=
        "Enter optional text describing whether this doctor is currently accepting new patients."
    )
    # patient portal flags
    patient_portal = models.CharField(
        max_length=200,
        blank=True,
        help_text="Enter a URL for this doctor's patient portal.")
    appointments = models.CharField(
        max_length=1,
        default=u'P',
        choices=PARTICIPATE,
        help_text=
        "Select Participates if this doctor participates in the Appointments feature."
    )
    portal_refill = models.CharField(
        max_length=1,
        default=u'P',
        choices=PARTICIPATE,
        help_text=
        "Select Participates if this doctor participates in the E-mail doctor feature."
    )
    email_staff = models.CharField(
        max_length=1,
        default=u'P',
        choices=PARTICIPATE,
        help_text=
        "Select Participates if this doctor participates in the E-mail staff feature."
    )
    lab_results = models.CharField(
        max_length=1,
        default=u'P',
        choices=PARTICIPATE,
        help_text=
        "Select Participates if this doctor participates in the Lab results feature."
    )
    portal_accounts = models.CharField(
        max_length=1,
        default=u'P',
        choices=PARTICIPATE,
        help_text=
        "Select Participates if this doctor participates in the Personal Health Records feature."
    )

    specialties = models.ManyToManyField(
        Specialty,
        blank=True,
        help_text="Select any number of specialties for this practitioner.")
    marketing_banner = models.ForeignKey(
        MarketingBanner,
        related_name="doctors_marketing_banner",
        blank=True,
        null=True,
        help_text=
        "Enter an additional marketing banner to be associated with this page."
    )

    class Meta:
        ordering = ['last_name']
        verbose_name_plural = "Doctors and Practitioners"

    def __unicode__(self):
        return self.name()

    def name(self):
        if self.suffix:
            name = u'%s %s %s, %s, %s' % (self.first_name, self.middle_name,
                                          self.last_name, self.suffix,
                                          self.letters)
        else:
            name = u'%s %s %s, %s' % (self.first_name, self.middle_name,
                                      self.last_name, self.letters)
        return name

    def display_name(self):
        if self.suffix:
            name = u'%s %s %s, %s' % (self.first_name, self.middle_name,
                                      self.last_name, self.suffix)
        else:
            name = u'%s %s %s' % (self.first_name, self.middle_name,
                                  self.last_name)
        return name

    def list_name(self):
        if self.suffix:
            name = u'%s, %s %s, %s' % (self.last_name, self.first_name,
                                       self.middle_name, self.suffix)
        else:
            name = u'%s, %s %s' % (self.last_name, self.first_name,
                                   self.middle_name)
        return name

    def remainder_name(self):
        if self.middle_name:
            name = u'%s %s' % (self.first_name, self.middle_name)
        else:
            name = u'%s' % (self.first_name)
        if self.suffix:
            name += u', %s' % (self.suffix)
        return name

    def title_service_name(self):
        if self.title_service:
            return self.title_service.name
        return None

    def is_accepting(self):
        return self.accepting_flag == 'A'

    def is_unterminated(self):
        if self.accepting[-1] in ['.', '!', '?']:
            return False
        return True

    def primary_location(self):
        return self.location_set.filter(position=1)[0]

    def has_extra_locations(self):
        return len(self.location_set.filter(position__gt=1)) > 0

    def extra_locations(self):
        return self.location_set.filter(position__gt=1)

    def services_links(self):
        link = ''
        more = False
        if self.title_service:
            if self.title_service.active != u'0':
                links = '<a href="%s">%s</a>' % (
                    self.title_service.get_absolute_url(),
                    self.title_service.name)
            else:
                links = '%s' % (self.title_service.name)
            more = True
        for service in self.services.iterator():
            if more:
                links += '; '
            if service.active != u'0':
                links += '<a href="%s">%s</a>' % (service.get_absolute_url(),
                                                  service.name)
            else:
                links += '%s' % (service.name)
            more = True
        return links

    def list_services(self):
        services = ''
        more = False
        if self.title_service:
            services = self.title_service.name
            more = True
        for service in self.services.iterator():
            if more:
                services += '; '
            services += service.name
            more = True
        return services

    def list_services_by_line(self):
        services = ''
        more = False
        if self.title_service:
            if self.title_service.active == '1':
                services = '<a href="{0}">{1}</a>'.format(
                    self.title_service.get_absolute_url(),
                    self.title_service.name)
            else:
                services = '{0}'.format(self.title_service.name)
            more = True
        for service in self.services.iterator():
            if more:
                services += '<br>'
            if service.active == '1':
                services += '<a href="{0}">{1}</a>'.format(
                    service.get_absolute_url(), service.name)
            else:
                services += '{0}'.format(service.name)
            more = True
        return services

    def practitioner_name(self):
        if self.title_service:
            return self.title_service.practitioner_name
        return None

    def get_absolute_url(self):
        return "/%s/%s/" % (self.item_url, self.urlname)

    def letter_key(self):
        return self.last_name[0]

    def get_degrees(self):
        if self.qa:
            degrees = self.degree_set.select_related().order_by(
                'doctors_degree_letters.sort_order')
        else:
            degrees = self.degree_set.model.objects.filter(
                doctor=self).select_related().order_by(
                    'doctors_degree_letters.sort_order')
        return degrees

    def get_accreditations(self):
        if hasattr(self, "qa") and self.qa:
            accreditations = self.accreditation_set.select_related().order_by(
                'doctors_accreditation_name.sort_order')
        else:
            accreditations = self.accreditation_set.model.objects.filter(
                doctor=self).select_related().order_by(
                    'doctors_accreditation_name.sort_order')
        return accreditations

    def get_nav_links(self):
        if hasattr(self, "qa") and self.qa:
            links = self.link_nav_set.select_related().order_by(
                'doctors_link_nav.position')
        else:
            links = self.link_nav_set.model.objects.filter(
                doctor=self).select_related().order_by(
                    'doctors_link_nav.position')
        return [x.resource for x in links]

    def get_hospitals(self):
        return self.hospitals.order_by('hospital')

    def blog_list(self):
        return self.blog.blogentry_set.all()[:5]

    # Portal links
    def participating(self):
        return (self.appointments in ('P', 'M')
                or self.portal_refill in ('P', 'M')
                or self.email_staff in ('P', 'M')
                or self.lab_results in ('P', 'M')
                or self.portal_accounts in ('P', 'M'))

    @property
    def get_portal_url(self):
        if self.patient_portal:
            return self.patient_portal
        else:
            return '/about/MySMG/'

    def has_portal_refill(self):
        if self.portal_refill in ('P', 'M'):
            return self.get_portal_url
        return False

    def has_email_staff(self):
        if self.email_staff in ('P', 'M'):
            return self.get_portal_url
        return False

    def has_appointments(self):
        if self.appointments in ('P', 'M'):
            return self.get_portal_url
        return False

    def has_lab_results(self):
        if self.lab_results in ('P', 'M'):
            return self.get_portal_url
        return False

    def has_portal_accounts(self):
        if self.portal_accounts in ('P', 'M'):
            return self.get_portal_url
        return False

    def pkstr(self):
        return u'%s' % self.pk

    def save(self, preview=True):
        super(Doctor, self).save(preview)
        cache.delete('finder-doctor-locations')
        cache.delete('finder-doctor-services-%s' % self.id)
        cache.delete('finder-doctor-specialty')
        cache.delete('finder-doctor-hospitals-%s' % self.id)
        cache.delete('finder-doctor-hospitals')
        cache.delete('finder-doctor-languages')

    def search_index(self):
        # Return a (key, url, order, display, name, body) tuple with text for indexing
        body = "%s " % self.name()
        topbody = "%s " % self.name()
        body += "%s " % unicode(self.title_service)
        topbody += "%s " % unicode(self.title_service)
        for service in self.services.all():
            body += "%s " % unicode(service)
        for degree in self.degree_set.all():
            body += "%s %s " % (degree.letters.letters, degree.description)
        for accreditation in self.accreditation_set.all():
            body += "%s %s " % (accreditation.name.name,
                                accreditation.description)
        for specialty in self.specialties.all():
            body += "%s " % (specialty.specialty)
        body += "%s " % unicode(self.touch)
        if self.suffix:
            display = '<a href="%s">%s, %s %s, %s, <span class="doctor_cred">%s</span></a> - <span class="doctor_dept">%s</span>' % (
                self.get_absolute_url(), self.last_name, self.first_name,
                self.middle_name, self.suffix, self.letters,
                self.list_services())
        else:
            display = '<a href="%s">%s, %s %s, <span class="doctor_cred">%s</span></a> - <span class="doctor_dept">%s</span>' % (
                self.get_absolute_url(), self.last_name, self.first_name,
                self.middle_name, self.letters, self.list_services())
        return SearchKey(self.pk, self.get_absolute_url(), self.last_name,
                         display, topbody, body)

    def keyword_index(self):
        if self.suffix:
            display = '<a href="%s">%s, %s %s, %s, <span class="doctor_cred">%s</span></a> - <span class="doctor_dept">%s</span>' % (
                self.get_absolute_url(), self.last_name, self.first_name,
                self.middle_name, self.suffix, self.letters,
                self.list_services())
        else:
            display = '<a href="%s">%s, %s %s, <span class="doctor_cred">%s</span></a> - <span class="doctor_dept">%s</span>' % (
                self.get_absolute_url(), self.last_name, self.first_name,
                self.middle_name, self.letters, self.list_services())
        # Return a (key, url, order, display, name, body) tuple with text for keyword indexing
        return SearchKey(self.pk, self.get_absolute_url(), self.last_name,
                         display, self.keywords, self.keywords)

    def display_image(self):
        if self.original_image:
            return self.original_image
        else:
            return static('images/no_doc_image.png')