-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[refs #112] Adds a new field to the Inspections model. #138
Open
vrocha
wants to merge
3
commits into
develop
Choose a base branch
from
feature/112-image-url
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import requests | ||
|
||
|
||
def check_image(url): | ||
"""Checks if an image url exists, returns True if the image exists.""" | ||
r = requests.get(url) | ||
if r.status_code == 200: | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
inspections/migrations/0003_auto__add_field_establishment_image_url.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# -*- coding: utf-8 -*- | ||
from south.utils import datetime_utils as datetime | ||
from south.db import db | ||
from south.v2 import SchemaMigration | ||
from django.db import models | ||
|
||
|
||
class Migration(SchemaMigration): | ||
|
||
def forwards(self, orm): | ||
# Adding field 'Establishment.image_url' | ||
db.add_column('inspections_establishment', 'image_url', | ||
self.gf('django.db.models.fields.URLField')(max_length=255, blank=True, default=''), | ||
keep_default=False) | ||
|
||
|
||
def backwards(self, orm): | ||
# Deleting field 'Establishment.image_url' | ||
db.delete_column('inspections_establishment', 'image_url') | ||
|
||
|
||
models = { | ||
'inspections.establishment': { | ||
'Meta': {'object_name': 'Establishment', 'unique_together': "(('external_id', 'county'),)"}, | ||
'address': ('django.db.models.fields.CharField', [], {'max_length': '255'}), | ||
'city': ('django.db.models.fields.CharField', [], {'max_length': '64'}), | ||
'county': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '64'}), | ||
'external_id': ('django.db.models.fields.CharField', [], {'max_length': '128'}), | ||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'image_url': ('django.db.models.fields.URLField', [], {'max_length': '255', 'blank': 'True'}), | ||
'location': ('django.contrib.gis.db.models.fields.PointField', [], {'null': 'True', 'blank': 'True'}), | ||
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), | ||
'opening_date': ('django.db.models.fields.DateTimeField', [], {}), | ||
'phone_number': ('django.db.models.fields.CharField', [], {'max_length': '64', 'blank': 'True'}), | ||
'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '16'}), | ||
'property_id': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'}), | ||
'state': ('django.db.models.fields.CharField', [], {'max_length': '64'}), | ||
'state_id': ('django.db.models.fields.BigIntegerField', [], {}), | ||
'status': ('django.db.models.fields.CharField', [], {'max_length': '32', 'default': "'active'"}), | ||
'type': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}), | ||
'update_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'db_index': 'True', 'blank': 'True'}) | ||
}, | ||
'inspections.inspection': { | ||
'Meta': {'object_name': 'Inspection'}, | ||
'date': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True'}), | ||
'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}), | ||
'establishment': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'inspections'", 'to': "orm['inspections.Establishment']"}), | ||
'external_id': ('django.db.models.fields.CharField', [], {'max_length': '128'}), | ||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'score': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), | ||
'type': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}), | ||
'update_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'db_index': 'True', 'blank': 'True'}) | ||
}, | ||
'inspections.violation': { | ||
'Meta': {'object_name': 'Violation'}, | ||
'code': ('django.db.models.fields.CharField', [], {'max_length': '32'}), | ||
'date': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True'}), | ||
'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}), | ||
'establishment': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'violations'", 'to': "orm['inspections.Establishment']"}), | ||
'external_id': ('django.db.models.fields.CharField', [], {'max_length': '128'}), | ||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||
'inspection': ('django.db.models.fields.related.ForeignKey', [], {'null': 'True', 'to': "orm['inspections.Inspection']", 'related_name': "'violations'", 'blank': 'True'}), | ||
'update_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'db_index': 'True', 'blank': 'True'}) | ||
} | ||
} | ||
|
||
complete_apps = ['inspections'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For production debugging, it might be nice if this task had a few
logger.debug
orlogger.info
statements to track what happened.