def type_or_project(request, slug): objects = Project.get_published().filter(project_type__slug=slug) if objects.count(): project_type = ProjectType.objects.language().get(slug=slug) title = _('Projects tagged "%s"' % project_type.title) meta = Meta( title=title, description=title, keywords=[project_type.title], image=objects[0].image.url, url=project_type.get_absolute_url(), ) context = {"meta": meta, "projects": objects, "type_title": title + ".", "subtitle": title} return render(request, "projects_type.html", context) else: project = get_object_or_404(Project.get_published(), slug=slug) next = False try: next = project.get_next_by_date(is_published=True) except: pass previous = False try: previous = project.get_previous_by_date(is_published=True) except: pass meta = Meta( title=project.title, description=project.explict_title + ". " + strip_tags(project.text), keywords=project.project_type.language().values_list("title", flat=True), image=project.image.url, url=project.get_absolute_url(), ) return render( request, "project.html", { "meta": meta, "project": project, "next": next, "previous": previous, "has_screenshots": project.screenshot_set.exists(), "subtitle": project.title, }, )
def cv(request): title = _(u'Curriculum Vitae, Resumé') meta = Meta( title=title, description=_('Andrey Shipilov') + ' / ' + title, keywords=['CV', 'Curriculum Vitae', u'Resumé'], ) context = { 'meta': meta, 'positions': Position.objects.all(), 'notable_projects': Project.get_notable(), 'subtitle': title, } return render(request, 'cv.html', context)
def home(request): auth = tweepy.OAuthHandler( TWITTER_SECRETS["andreyshipilov"]["consumer_key"], TWITTER_SECRETS["andreyshipilov"]["consumer_secret"] ) auth.set_access_token( TWITTER_SECRETS["andreyshipilov"]["access_token"], TWITTER_SECRETS["andreyshipilov"]["access_token_secret"] ) api = tweepy.API(auth) try: tweets = api.user_timeline("andreyshipilov") except: tweets = None try: twitter_info = api.get_user("andreyshipilov") except: twitter_info = None if tweets and twitter_info: frequency = (datetime.today() - twitter_info.created_at).days / len(tweets) else: frequency = int() projects = Project.get_published() meta = Meta( url="/", image=projects[0].image.url, title=_("Andrey Shipilov"), description=strip_tags(_("Some text about me")), ) context = { "is_home": True, "meta": meta, "tweets": tweets, "tweet_frequency": frequency, "twitter_info": twitter_info, "projects": projects[:33], "projects_count": projects.count(), } return render(request, "home.html", context)
def projects(request): project_types = ProjectType.objects.language().all().distinct() projects = Project.get_published() meta = Meta( title=_("Projects"), description=_("Andrey Shipilov's projects"), keywords=[x.title for x in project_types], image=projects[0].image.url, url=request.path_info, ) return render( request, "projects.html", { "is_types": True, "meta": meta, "project_types": project_types, "projects": projects, "subtitle": _("Projects"), }, )
import sys from urllib2 import urlopen import django from django.core.mail import send_mail os.environ.setdefault("DJANGO_SETTINGS_MODULE", "andreyshipilov.settings.prod") django.setup() # Is verbose output needed? IS_VERBOSE = True if '-v' in sys.argv else False # Get projects from models. from me.models import Project projects = Project.get_published().filter(is_alive=True, link__startswith="http://") \ .values('link', 'slug') # List of bad hosts. pinged_bad = [] for i in projects: try: # Trying to get any response. response = urlopen(i['link'], timeout=30) if IS_VERBOSE: print "+ '%s' is OK" % (i['slug'],) except: pinged_bad.append("%s: %s" % (i['slug'], i['link'])) if IS_VERBOSE: